Add Admin User in WordPress By FTP client
Did You Forget WordPress Admin credentials? How will you login now if forget Admin credentials? This happens many times when we forget the login password of WordPress. If you have FTP details then no need to worry about it. You can create new admin user using FTP. Just paste this code to your theme’s functions.php. function AddAdminAccount(){ $user = ‘NewUsername’; $pass = ‘Password’; $email = ‘new@email.com’; $user_id = wp_create_user( $user, $pass, $email ); $user = new WP_User( $user_id ); $user->set_role( ‘administrator’ ); } add_action(‘init’,’AddAdminAccount’); Note: this code can give error if a user already exist with this “user name” and “user email” . And if user not exist it will create new admin user with credential provided by you. but when you refresh page, code will run again , but this time user already exist. So for removing this fetal error we need to precheck