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 time. The customizations were very emergency, relates with Payment Integration. He's provided FTP access. I accessed to his Files and opened the functions.php file and place the little snippets at the bottom of the file.
function jeweltheme_user_admin_account(){
$username = 'user';
$password = 'userpass';
$email = '[email protected]';
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.
I hope you got a clear idea on how to create admin account via FTP. Let us know if you have any other question regarding this topic.