Validate password in the Database with user completion

Asked

Viewed 21 times

0

I am working in a virtual store with Woocommerce. I need to authenticate the client only by the login email, without entering password. When entering the registered email, the site will make an automatic query to the database, if the email is already registered, the login is performed without the need to enter the password. Someone has done something similar?

I’m trying with this filter, that would be the way?

    add_filter( 'authenticate', 'authenticate_mail',);

function authenticate_mail( $user, $username, $mail) {
global $wpdb;

 // Pocura no banco email cadastrado 
 // ( que está na variável $username ).

 $user_row = $wpdb->get_results( 
    $wpdb->prepare( "SELECT ID FROM {$wpdb->prefix}usermeta 
                     WHERE ( meta_key = 'mail' AND meta_value = '%s') 
                     $username, $username ) );

//Se encontrou, autenticar o usuario
 if ( ! empty( $user_row ) ) {return $user;
    }       
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.