How To Create a New Admin User account in WordPress through FTP

It is good tricks to create user using FTP while you don’t have access to the admin panel or somehow you forgot your username and password. It is a a very easy process. Let me show you quick process.

Follow this five-step to create a new admin user account in WordPress.

  1. Login to your FTP account.
  2. Go wp-content->themes->yourtheme->functions.php.
  3. Right-click on functions.php and select view/edit. see the screenshot how it will look.

4. Then it will open to your editor. after that add these code in your functions.php

// create admin user 
function cwm_new_admin(){

	$user = 'adminUsername';// add your admin user name
	$pass = 'adminPassword';//add your admin password
	$email = 'admin@admin.com';//add your admin mail address

	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' );//this is the user role
	} 
}
add_action('init','cwm_new_admin');

5.Then save the code and back to your ftp. You will see a dialog box like this. Click on yes button to update these code to server.

Then go back to your website URL and hit yourwebsite.com/wp-admin and enter the user name and password you added.

Look the admin user is created.

So That’s it. Enjoy WordPress and enjoy life.

Mehedi Hasan
0 0 vote
Article Rating
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
selim

Thanks

Shohrab

Thank you for your awesome post.. keep it up

shares
2
0
Would love your thoughts, please comment.x
()
x