Have you forgotten your WordPress password and email? Add an Admin User in WordPress using FTP.

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.

Sazzad Mahmud
Sazzad Mahmud

Hello, I am a WordPress Consultant. My WordPress Consultancy service goes beyond designing and developing WordPress sites. I can advise you on the overall strategy of the website, help optimize a website’s performance, improve conversions, provide security and disaster recovery strategy, develop marketing funnels and improve SEO. Let’s work on a great project together