July 22, 2020
If you’ve forgotten what email and password you used to setup a website (or entered your email wrong, or your website isn’t sending reset password links to you!), you can setup an admin user via FTP using the following function.
Add to functions.php
function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = '[email protected]';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');
Remember to update Username, Password and Emails from the defaults shown above!
Source. #22 in the list.