If you have forgotten your WordPress email and password, you can add an admin user by adding the below code to the functions.php file in your theme using an FTP client.
function sms_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','sms_admin_account');
Don’t forget to replace the Username, Password, and [email protected] with your actual information.
Now go to the login page of your WordPress website. Log in with the information you just added. Don’t forget to remove the code you have added in the functions.php file after logging in to your WordPress website. Don’t worry; removing the code will not remove the user you created.