1

我正在使用用于 Wordpress 的 Mingle 插件供用户注册,以便他们可以在 Mingle 论坛上发帖。

注册过程有效,但我想在用户提交详细信息后将其重定向到论坛页面,而不是仅仅停留在注册页面上。

我尝试添加<input type="hidden" name="redirect_to" value="<?php echo bloginfo('url'); ?>" />代码以使页面重定向(因为它在登录表单上工作),但似乎不适用于注册表单。

我也尝试在表单详细信息中使用“操作”功能;这会重定向页面,但不提交数据。

该页面的代码如下 - 如果可能的话,非常感谢您的解决方案!谢谢。

<form name="registerform" id="registerform" method="post">
<input type="hidden" id="mngl-process-form" name="mngl-process-form" value="Y" />
<input type="hidden" name="redirect_to" value="http://creativespotlights.com/forum" action="http://creativespotlights.com/forum" />
<p>
    <label><?php _e('Username', 'mingle'); ?>*:<br />
    <input type="text" name="user_login" id="user_login" class="input mngl_signup_input" value="<?php echo $user_login; ?>" size="20" tabindex="200" /></label>
</p>
<p>
    <label><?php _e('E-mail', 'mingle'); ?>*:<br />
    <input type="text" name="user_email" id="user_email" class="input mngl_signup_input" value="<?php echo $user_email; ?>" size="25" tabindex="300" /></label>
</p>
<?php if(isset($mngl_options->field_visibilities['signup_page']['name'])) { ?>
  <p>
      <label><?php _e('First Name', 'mingle'); ?>:<br />
      <input type="text" name="user_first_name" id="user_first_name" class="input mngl_signup_input" value="<?php echo $user_first_name; ?>" size="20" tabindex="400" /></label>
  </p>  
  <p>
    <label><?php _e('Last Name', 'mingle'); ?>:<br />
    <input type="text" name="user_last_name" id="user_last_name" class="input mngl_signup_input" value="<?php echo $user_last_name; ?>" size="20" tabindex="500" /></label>
  </p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['url'])) { ?>
  <p>
    <label><?php _e('Website', 'mingle'); ?>:<br />
    <input type="text" name="mngl_user_url" id="mngl_user_url" value="<?php echo $mngl_user_url; ?>" class="input mngl_signup_input" size="20" tabindex="600"/></label>
  </p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['location'])) { ?>
  <p>
    <label><?php _e('Location', 'mingle'); ?>:<br />
    <input type="text" name="mngl_user_location" id="mngl_user_location" value="<?php echo $mngl_user_location; ?>" class="input mngl_signup_input" size="20" tabindex="700" /></label>
  </p>
<?php } ?>
<?php if(isset($mngl_options->field_visibilities['signup_page']['bio'])) { ?>
  <p>
    <label><?php _e('Bio', 'mingle'); ?>:<br />
    <textarea name="mngl_user_bio" id="mngl_user_bio" class="input mngl-growable mngl_signup_input" tabindex="800"><?php echo wptexturize($mngl_user_bio); ?></textarea></label>
  </p>
<?php } ?>  
<?php if(isset($mngl_options->field_visibilities['signup_page']['sex'])) { ?>
  <p>
    <label><?php _e('Gender', 'mingle'); ?>*:&nbsp;<?php echo MnglProfileHelper::sex_dropdown('mngl_user_sex', $mngl_user_sex, '', 900); ?></label>
  </p>
<?php } ?>

<?php if(isset($mngl_options->field_visibilities['signup_page']['password'])) { ?>
  <p>
    <label><?php _e('Password', 'mingle'); ?>:<br/>
    <input type="password" name="mngl_user_password" id="mngl_user_password" class="input mngl_signup_input" tabindex="1000"/></label>
  </p>
  <p>
    <label><?php _e('Password Confirmation', 'mingle'); ?>:<br />
    <input type="password" name="mngl_user_password_confirm" id="mngl_user_password_confirm" class="input mngl_signup_input" tabindex="1100"/></label>
  </p>
<?php } else { ?>
    <p id="reg_passmail"><?php _e('A password will be e-mailed to you.', 'mingle'); ?></p>
<?php } ?>
<?php if($mngl_options->signup_captcha) { ?>
<?php
   $captcha_code = MnglUtils::str_encrypt(MnglUtils::generate_random_code(6));
?>
<p>
<label><?php _e('Enter Captcha Text', 'mingle'); ?>*:<br />
<img src="<?php echo MNGL_SCRIPT_URL; ?>&controller=captcha&action=display&width=120&height=40&code=<?php echo $captcha_code; ?>" /><br/>
<input id="security_code" name="security_code" style="width:120px" type="text" tabindex="1200" />
<input type="hidden" name="security_check" value="<?php echo $captcha_code; ?>">
</p>
<?php } ?>
  <?php do_action('mngl-user-signup-fields'); ?>

    <br class="clear" />
    <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="mngl-share-button" value="<?php _e('Sign Up', 'mingle'); ?>" tabindex="60" />
</p>
</form>
4

4 回答 4

3

尝试这个

<?php    
if (isset($_POST['wp-submit']))
    {   
        header('Location: http://site/result.php');       
    }
?>

在代码的顶部

或者你可以尝试通过javascript使用 onsubmit="window.location.href='result.php';"

于 2013-04-20T15:56:03.927 回答
2

您可以使用 :

header('Location: http://yoursite.com/location.php');

但是你必须得到一个干净的输出(标题前没有 html)。

文档在这里

于 2013-04-20T15:04:38.967 回答
1

成功提交表单后,您应该执行303 重定向到同一页面。如果用户碰巧按 F5 或其他表单或重新加载页面,这样做将防止重新提交表单。

wp_redirect("/path/to/my/script", 303);

您需要替换/path/to/my/script为表单所在的 URL。

于 2013-11-05T00:51:42.037 回答
1

像这样的东西应该工作:

if (isset($_POST['user_login']))
{
    (your redirect code here)
}
于 2013-04-20T15:24:32.160 回答