Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用户在wordpress中通过电子邮件登录不起作用_Php_Wordpress - Fatal编程技术网

Php 用户在wordpress中通过电子邮件登录不起作用

Php 用户在wordpress中通过电子邮件登录不起作用,php,wordpress,Php,Wordpress,我一直在尝试启用用户通过电子邮件登录。我在中找到了在functions.php中编写以下代码的方法 add_action( 'wp_authenticate', 'wp_authenticate_by_email' ); function wp_authenticate_by_email( $username ) { $user = get_user_by( 'email', $username ); if ( empty( $user ) ) { return;

我一直在尝试启用用户通过电子邮件登录。我在中找到了在functions.php中编写以下代码的方法

add_action( 'wp_authenticate', 'wp_authenticate_by_email' );

function wp_authenticate_by_email( $username ) {
$user = get_user_by( 'email', $username );

   if ( empty( $user ) ) {
       return;
   }

return $user->user_login;
}

但这对我不起作用。我发现它和以前一样

我也遇到过类似的问题,但我成功地解决了这个问题:

function my_authenticate_by_email( $user, $username, $password ) {
    //try to get user by email
    $user = get_user_by( 'email', $username );
    //validate we got a user.
    if ($user && !is_wp_error($user))
    {
        //use normal auth
        return wp_authenticate_username_password(null, $user->user_login, $password); 
    }
    //continue to next filter, like normal.
    return null;
}
add_filter( 'authenticate', 'my_authenticate_by_email', 0, 3);

请从给定的博客链接中正确复制代码。是的,我明白,但它实际上不起作用。但是,我使用的是最新版本的wordpress。你需要删除默认的登录过滤器才能使用你的扫描。你能帮我吗