Reset WordPress password using FTP only

by | May 17, 2017 | Miscellaneous | 0 comments

Sometimes, you get yourself locked outside wordpress without any way to reset your password using email and you don’t have database access. So here is the simplest way to reset your password without database access, only FTP is required.

  1. Create new file inside you website root (beside wp-config.php, outside wp-content), lets call this file forgot-password.php
  2. Add this code to the file. ( Replace parameters with your own details)
     <?php include 'wp-load.php';
    
    $user = get_user_by( 'email', 'email@titrias.com' );
    //$user = get_user_by( 'slug', 'titrias' );
    //$user = get_user_by( 'login', 'login' );
    wp_set_password( "new_password", $user->ID );
    
    // Just use ID=1 for the super admin account
    //wp_set_password( "new_password", 1 );
    
    die("Done");
  3. You can use email, slug or login name to get the user id. If you want to reset the super admin password, use ID=1.
  4. Upload the file and call it from your browser: www.website.com/forgot-password.php
  5. After calling this file once, DON’T FORGET TO REMOVE THE FILE.

 

Tags:

Tags

Have a great idea to implement? We can help

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *