我在几个WordPress网站上看到注册过程分为3到4个步骤。
我如何将这样的过程实现到我的主题中?ie:
选择您的角色并填写注册表--->如果可以提交,则转到步骤2
配置文件详细信息:用户pic,一些用户元表单---<;如果可以提交,请在确认之前执行步骤3预览配置文件---<;转至步骤4或返回步骤3进行更改注册成功UPDATE 嗨,伙计们,我已经了解了一点,(我正在使用jobroller主题,它有一个普通的一步注册表单,但它有一个多步骤表单用于代理工作列表)submit job form. 我想要的是使用相同的注册表格(提交工作多步骤表格),这样用户就有义务在同一流程中填写个人资料或其他信息。登记因此,我入侵了jobroller主题的原始注册(includes/theme-login.php)及其提供的内容。
theme-login.php
以下是替换原始函数的函数注册步骤jr_register_form()
function jr_registration_steps() {
// Show registration steps forms
### Prevent Caching
nocache_headers();
jr_load_form_scripts();
//global $post, $posted;
global $posted;
$submitID = $post->ID;
$posted = array();
$errors = new WP_Error();
if (!is_user_logged_in()) :
$step = 1;
else :
$step = 2;
if (!current_user_can(\'can_submit_job\')) : //can_submit_listing redirect to my listing
redirect_myjobs();
endif;
endif;
if (isset($_POST[\'register\']) && $_POST[\'register\']) {
$result = jr_process_register_form( get_permalink($submitID) );
$errors = $result[\'errors\'];
$posted = $result[\'posted\'];
//}
//elseif (isset($_POST[\'login\']) && $_POST[\'login\']) {
//$errors = jr_process_login_form();
}
elseif (isset($_POST[\'job_submit\']) && $_POST[\'job_submit\']) {
$result = jr_process_submit_job_form();//jr_process_submit_user_registration_form
$errors = $result[\'errors\'];
$posted = $result[\'posted\'];
if ($errors && sizeof($errors)>0 && $errors->get_error_code()) $step = 2; else $step = 3;
}
elseif (isset($_POST[\'preview_submit\']) && $_POST[\'preview_submit\']) {
$step = 4;
$posted = json_decode($_POST[\'posted\']);
}
elseif (isset($_POST[\'confirm\']) && $_POST[\'confirm\']) {
$step = 4;
jr_process_confirm_job_form();//jr_process_confirm_user_registration_form
}
elseif (isset($_POST[\'goback\']) && $_POST[\'goback\']) {
$posted = json_decode(stripslashes($_POST[\'posted\']), true);
}
if( isset($_GET[\'checkemail\']) && \'newpass\' == $_GET[\'checkemail\'] )
$message = __(\'Thank you for registering! An email has been sent to you containing your password.\',\'appthemes\');
get_template_part(\'header\'); ?>
<div class="section">
<div class="section_content">
<h1><?php _e(\'create an Account\', \'appthemes\'); ?></h1>
<?php
echo \'<ol class="steps">\';
for ($i = 1; $i <= 4; $i++) :
echo \'<li class="\';
if ($step==$i) echo \'current \';
if (($step-1)==$i) echo \'previous \';
if ($i<$step) echo \'done\';
echo \'"><span class="\';
if ($i==1) echo \'first\';
if ($i==4) echo \'last\';
echo \'">\';
switch ($i) :
case 1 : _e(\'Create account\', \'appthemes\'); break;
case 2 : _e(\'Enter Profile Details\', \'appthemes\'); break;
case 3 : _e(\'Preview/Profile Options\', \'appthemes\'); break;
case 4 : _e(\'Confirm\', \'appthemes\'); break;
endswitch;
echo \'</span></li>\';
endfor;
echo \'</ol><div class="clear"></div>\';
// show the success message usually because a password has been emailed to new user
if (isset($message) && !empty($message)) echo \'<p class="success">\'.$message.\'</p>\';
jr_show_errors( $errors );
switch ($step) :
case 1 :
jr_before_step_one(); // do_action hook
?>
<p><?php _e(\'You must login or create an account in order to post a job — this will enable you to view, remove, or relist your listing in the future.\', \'appthemes\'); ?></p>
<div class="col-1">
<?php jr_register_form( get_permalink($submitID), \'job_lister\' ); ?> <!-- change job_lister to new role--->
</div>
<div class="col-2">
<?php jr_login_form( get_permalink($submitID), get_permalink($submitID) ); ?> <!-- delete--->
</div>
<div class="clear"></div>
<?php
jr_after_step_one(); // do_action hook
break;
case 2 :
jr_before_step_two(); // do_action hook
jr_submit_job_form(); //*****jr_submit_user_registration_form();
jr_after_step_two(); // do_action hook
break;
case 3 :
jr_before_step_three(); // do_action hook
jr_preview_job_form(); //*****jr_preview_user_registration_form();
jr_after_step_three(); // do_action hook
break;
case 4 :
jr_before_step_four(); // do_action hook
jr_confirm_job_form(); //*****jr_confirm_user_registration_form();
jr_after_step_four(); // do_action hook
break;
endswitch;
?>
</div><!-- end section_content -->
</div><!-- end section -->
<div class="clear"></div>
<?php if (get_option(\'jr_show_sidebar\')!==\'no\') get_sidebar(\'submit\'); ?>
<?php
get_template_part(\'footer\');
}
这里是我的includes/forms/register/register流程中的内容。phpregister-process.php
请注意,我已在底部对此进行了修改:// redirect
wp_redirect($success_redirect);
wp_redirect($success_redirect);// redirect user to dashbord when registred
exit();
对于此代码:$redirect_to = !empty( $_POST[\'redirect_to\'] ) ? $_POST[\'redirect_to\'] : \'?action=register&step=2\';
wp_safe_redirect( $redirect_to );
exit;
为了添加&step=2
对于url,我想您可以在另一个表单中添加类似的代码来重定向并在url中显示正确的步骤?动作=寄存器我还没有完成对代码的修改,以满足我的需要,但我建议使用beginin,其他人可以帮助修改或更好地呈现。
希望它能帮助您:)