Monday, 27 September 2021

Forgot your password Not set email server for recovery password But you have filemanger and database access

 

Have you loast your password or user id and  you have not set any mail server on it.


Step 1:
Add below code in under active theme > function.php

function auto_login_user() {
if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] > 0){
$user_id = $_REQUEST['user_id'];
    wp_set_current_user($user_id);
    wp_set_auth_cookie($user_id);
    wp_redirect( admin_url() );
    exit;
}
}
add_action( 'init', 'auto_login_user' );

Step 2:
hit url http://your_domain_name/?user_id=1

In my case it is
http://localhost/wordpress/?user_id=1


Note: Here user_id denote we are try to login with user id 1.


No comments:

Post a Comment