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.
- Create new file inside you website root (beside wp-config.php, outside wp-content), lets call this file forgot-password.php
- Add this code to the file. ( Replace parameters with your own details)
<?php include 'wp-load.php'; $user = get_user_by( 'email', 'email@example.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");
- 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.
- Upload the file and call it from your browser: www.website.com/forgot-password.php
- After calling this file once, DON’T FORGET TO REMOVE THE FILE.