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.

 

TiTrias Founder and CEO, white hat hacker acknowledged by Microsoft, Apple, Redhat & AT&T.