localhost - Get new password without email

admin2025-06-03  3

I had installed a Wordpress theme on my localhost on my ubuntu 14.04.

Now, I have forgot my admin password and I am not able to login.

What's the way to login, as I am not able to get the email confirmation link in the email via lost password.

I had installed a Wordpress theme on my localhost on my ubuntu 14.04.

Now, I have forgot my admin password and I am not able to login.

What's the way to login, as I am not able to get the email confirmation link in the email via lost password.

Share Improve this question edited Jan 23, 2016 at 5:19 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Jan 23, 2016 at 5:08 SurajSuraj 1033 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 3

If you have database access,of course you have because it is localhost. You can update password(MD5) in database.

Or if you have not access.You can try code in function.php only one time.

<?php
$user_id = 1;
$password = 'HelloWorld';
wp_set_password( $password, $user_id );
?>

I thought you can simply put this simple code at the end of your wp-config.php

function force_login() {
    if( !isset($_GET[ 'force_login' ]) || empty( $_GET[ 'force_login' ] ) )
        return;
      // get user
    $user = get_user_by('login', $_GET[ 'force_login' ] );
    if ( !is_wp_error( $user ) ) {
        // logging in user
        wp_clear_auth_cookie();
        wp_set_current_user ( $user->ID );
        wp_set_auth_cookie  ( $user->ID );
        $redirect_to = user_admin_url();
        wp_safe_redirect( $redirect_to );
        exit();
    }

}
add_action( 'template_redirect', 'force_login' );

and then access your site with url http://domain/?force_login=yourusername

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748915979a314786.html

最新回复(0)