脚本宝典收集整理的这篇文章主要介绍了php – WordPress两步注册表,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
第一步:要有2个输入字段(名称,电子邮件),用户提交后,将发送一个电子邮件,并链接到第二步.
第二步:用户输入发送到他的电子邮件的链接,输入第二个表单的页面.它具有使用的电子邮件和名称的价值,以及他将访问某些页面的其他2个字段(用户名,密码).
我找不到从哪里开始,没有插件符合以下要求.
问候,
穆斯塔法.
首先,您应该创建两个单独的模板(每个步骤一个).
在第一个模板中,您应该创建一个将用户电子邮件发送到第二个页面的表单.该链接应具有GET属性,以便您可以获取他的电子邮件和名字.这是一个例子(注意它可以改进):
<?PHP /* ** Template Name: Step 1 */ get_header(); if ( !empty( $_POST['Firstname'] ) && !empty( $_POST['email'] ) ) { $link = 'http://my-sITe/step-2'; $link = add_query_arg( array( 'firstname' => $_POST['firstname'],'email' => $_POST['email'],),$link ); $subject = 'New user registration'; $message = 'Please click on the following link to complete your registration: ' . $link; $headers = array('Content-tyPE: text/htML; charset=UTF-8'); $result = wp_mail( $_POST['email'],$subject,$message,$headers ); if ( $result ) { $message = 'Please check your email address to complete the registration'; } else { $message = 'Something went wrong. Please contact the administrator'; } echo $message; } else { ?> <form method="POST" action=""> <input type="text" name="firstname" placeholder="First Name"> <input type="email" name="email" placeholder="Email address"> <input type="submit" value="Submit"> </form> <?PHP } get_footer();
我们创建一个简单的检查,如果表单被提交,所有的字段都被填充.
如果是这样,我们可以发送电子邮件到第2步.
第2步
我们将创建一个单独的模板,我们将使用$_GET填充第一个数据,我们将添加两个将为空的新字段(用户名和密码).
<?PHP /* ** Template Name: Step 2 */ get_header(); if ( !empty( $_POST['firstname'] ) && !empty( $_POST['email'] ) && !empty( $_POST['password'] ) ) { $user_id = username_exists( $_POST['username'] ); if ( !$user_id and email_exists($_POST['email']) == false ) { $user_id = wp_create_user( $_POST['username'],$_POST['password'],$_POST['email'] ); if ( $user_id ) { update_user_Meta($user_id,'first_name',$_POST['firstname']); $message = 'User has been created'; } } else { $message = 'User already exists!'; } echo $message; } else { ?> <form method="POST" action=""> <input type="text" name="firstname" value="<?PHP echo ( !empty( $_GET['firstname'] ) ) ? $_GET['firstname'] : '' ; ?>" placeholder="First Name"> <input type="email" name="email" value="<?PHP echo ( !empty( $_GET['email'] ) ) ? $_GET['email'] : '' ; ?>" placeholder="Email Address"> <input type="text" name="username" placeholder="Username"> <input type="password" name="password" placeholder="Password"> <input type="submit" value="Submit"> </form> <?PHP } get_footer();
以上是脚本宝典为你收集整理的php – WordPress两步注册表全部内容,希望文章能够帮你解决php – WordPress两步注册表所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。