X

Create User Admin Account on WordPress via FTP/PHP

Here is a little snippet which can create a WordPress backend account with ease using the FTP, just paste this PHP snippet in the active theme’s functions.php and the account will be created. Also, make sure the username and the email are unique, or the function will fail.

If you forgot your Website's Control or WordPress Username/Password. If you've only FTP access to access the files then you can create WordPress Admin Account very easily. After that you can access on your Dashboard via your new User Admin account.

Few days ago I was working on a Client's WordPress Site. He was forgot his Control Panel's Password. At that time it's impossible to contact with Hosting Support because it will take some times. The customization's were very emergency, relates with Payment Integration. He's provided FTP access. I accessed to his Files and opened functions.php file and place the little snippets at the bottom of the file.

function jeweltheme_user_admin_account(){
 $username = 'UserName';
 $password = 'UserAccountPassword';
 $email = 'email@domain.com';
 if ( !username_exists( $username )  && !email_exists( $email ) ) {
  $user_id = wp_create_user( $username, $password, $email );
  $username = new WP_User( $user_id );
  $username->set_role( 'administrator' );
 } 
}
add_action('init','jeweltheme_user_admin_account');

The function above will creates an Administrator account. It will be an Administrator account with full features of websites. You can create other user accounts like Author, Editor, Contributor or Subscribers.

Above function used WP_User() Class. Learn more about WP_User.

Learn more about user Roles and Capabilities.

If you want to Create custom Roles and Controls the Roles and Capabilities then read this article.

Create User Admin Account on WordPress via FTP/PHP was last modified: May 26th, 2018 by Liton Arefin

This post was last modified on May 26, 2018, 4:00 pm

Categories: Tutorials
X

Enable Cookies

We use cookies for better performance. We collect emails as per your interest not for spamming. We hate spam. You're completely safe with us.

For More information about Privacy Click Here
Privacy Settings

This website uses cookies for better User Experience.