Categories
WordPress

How to create WordPress admin user by using FTP

Somehow you forget your username password or user email address or being locked in your WordPress admin is frustrating.

Why and when you need this?

You forget the admin user password or email address on one of the wordpress landing pages of your website and can’t login to site backend. You can change the admin user password MySQL (most of using phpMyAdmin via cPanel) but when you have no access to the cPanel or you don’t want this way but you have the FTP access!

How to add WordPress admin account via FTP?

So, already you know, you need the FTP access to create an admin account. Login to the FTP client software. Once connected with your site go to the /wp-content/themes/YOURTHEMENAME/functions.php Now, right click o the functions.php file and click on the “View/Edit/Modify” Once downloaded functions.php file add this code on the page bottom.

function add_admin_acct(){
 $login = 'demo';
 $passw = 'demo';
 $email = '[email protected]';

if ( !username_exists( $login )  && !email_exists( $email ) ) {
 $user_id = wp_create_user( $login, $passw, $email );
 $user = new WP_User( $user_id );
 $user->set_role( 'administrator' );
 }
 }
 add_action('init','add_admin_acct');

  Don’t forget to replace Username, Password, and email with your own values. Next, save functions.php file and then upload it back to your website theme folder using the FTP client. Now you can visit your WordPress site’s login area and sign in with the user account just you added. After successfully login to your site, don’t forget to delete that code from functions.php file. I hope, this post helped you learn “How to create WordPress admin user by using FTP”. If you need my assistance, please comment back. Have a wonderful day.

By Murshid Alam

Organizer of Barishal WordPress Meetup, WordPress Enthusiastic and, Open Source Lover. Over the last few years, I learned web programming and worked with them locally. I also assist in designing, developing and testing websites too!

Before coming to web programming I was mostly involved with Electric Media(Channel i), Newspaper (Priyo, Bhorer Kagoj) and volunteering activities (including NGOs).

I love to contribute to the WordPress Community. I am always happy to meet new peoples in the WordPress community and see how I can help them achieve their goals. When I am not online and WordPress, I love to play football, travel, riding the bike and attend Meetup/WordCamps!

If you’d like, you can help me to attend WordCamps around the World.

Leave a Reply