如何在默认的WordPress注册中添加密码字段? [英] How to add password fields to a default WordPress registration?

查看:99
本文介绍了如何在默认的WordPress注册中添加密码字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让用户选择自己的密码,但保留验证电子邮件(不重置密码链接)吗?

I woulrd like to enable users to choose their own passord, but keep a verification email(without reseting password link)?

我正在wp-login中添加密码的输入字段:

I am adding an input field for the password in wp-login:

<input type="password" name="user_password" value="" placeholder="Password" id="user_password" class="input" />

然后,我有一个用于设置用户密码的自定义插件:

Than, I have a custom plugin thats sets user's password:

function myplugin_registration_change_pass( $user_id ) 

{if ( isset( $_POST['user_password'] ) )
    wp_set_password( $_POST['user_password'], $user_id );}

出于某种原因,我一直收到要求用户设置密码的验证电子邮件. 知道如何解决这个问题吗?

For some reason I keep getting verification email asking the user to set a password. ANy ideas how I can solve this?

推荐答案

<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
<p>
    <label for="user_login"><?php _e('*First Name') ?><br />
    <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="25" /></label>
</p>
<p>
    <label for="user_login"><?php _e('*Last Name') ?><br />
    <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="25" /></label>
</p>


<p>

    <label for="user_login"><?php _e('*Username') ?><br />
    <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="25" /></label>
</p>
<p>
    <label for="user_email"><?php _e('*Email address') ?><br />
    <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
</p>

<p>
    <label for="user_login"><?php _e('*Choose a password') ?><br />
    <input type="text" name="user_password" id="user_password" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="25" /></label>
</p>
<p>
    <label for="user_login"><?php _e('*Confirm password') ?><br />
    <input type="text" name="user_password" id="user_password" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="25" /></label>
</p>
<p>
    <input type="checkbox" name="vehicle" value="Bike" onclick="return false" checked >I agree to the terms and conditions<br>
</p>

在某些时候访问wp-login.php时,您具有用于用户注册的这些字段.我添加了名字,姓氏和密码.我还创建了一个小插件,用于在输入字段中设置密码:

When you go to wp-login.php at some point you have these fields for user registration. I added first, last name and password.I also created a small plugin that sets the password from the input field:

function myplugin_set_pass( $user_id ) 
{if ( isset( $_POST['user_password'] ) )
wp_set_password( $_POST['user_password'], $user_id );}
add_action('user_register','myplugin_set_pass')

我想说的是,在用户注册时,应执行插件的功能.换句话说,应该设置密码.我不确定这是否正确.

With the line line I am saying that on user registration the function from the plugin should be performed. In other words the password should be set. I am not really sure if that is the right track.

这篇关于如何在默认的WordPress注册中添加密码字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆