这是我的一个客户案例。
首先我们来看一下官方文档的说明:
As of WP 4.3, a plain text password is no longer passed to the function. If you have a plugged version of this function and are assuming that the second function argument is $plaintext_pass
, the password displayed in your email to the user will be "admin" or "both".
大概的意思是:在WP 4.3版本中,纯文本密码将不会传递给函数,在您的电子邮件中密码将被显示成“admin”或“both”。
其实在WP 4.3用户注册机制已经发生改变,用户现在需要点击邮箱中发来的链接,自己设置密码。
把插件修改成类似以下代码吧,官方文档的不好使,会提示验证链接不对。
- <?php
-
-
-
-
-
-
- if ( !function_exists('wp_new_user_notification') ) {
-
- function wp_new_user_notification( $user_id, $notify = '' ) {
-
- global $wpdb;
- $user = new WP_User( $user_id );
-
- $user_login = stripslashes( $user->user_login );
- $user_email = stripslashes( $user->user_email );
-
- if ( 'admin' === $notify || emptyempty( $notify ) ) {
- return;
- }
-
-
- $key = wp_generate_password( 20, false );
-
- do_action( 'retrieve_password_key', $user->user_login, $key );
-
-
- if ( emptyempty( $wp_hasher ) ) {
- require_once ABSPATH . WPINC . '/class-phpass.php';
- $wp_hasher = new PasswordHash( 8, true );
- }
-
- $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
- $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
-
- $message .= "您已注册成为工匠律师用户!下面是您的账户信息:\r\n\r\n";
-
- $message .= sprintf(('Username: %s'), $user->user_login) . "\r\n\r\n";
- $message .= ('To set your password, visit the following address:') . "\r\n\r\n";
- $message .= network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login');
-
- wp_mail(
- $user_email,
- sprintf( __('[%s] Your username and password info'), get_option('blogname') ),
- $message
- );
- }
- }