0

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.

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 );
?>
| improve this answer | |
0

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.com/?force_login=yourusername

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.