Create new WordPress admin user over FTP

Sometime you need to create new admin user without access to dashboard. We know how to do it over SQL database and here is how to do it over FTP.

Add new admin in WordPress over FTP by editing function.php

All what you will need is just an ordinary FTP access. Locate your function.php file (the path to file is wp-content/themes/yourthemetheme). Open function.php file in any text editor and paste following PHP code snippet:

//Note: Remove following snippet after new user had been created!!!
function new_admin_account()
    $user = 'NewUsername';
    $pass = 'NewPassword';
    $email = 'namel@domain.tld';
    if (!username_exists($user) && !email_exists($email)) {
        $user_id = wp_create_user($user, $pass, $email);
        $user = new WP_User($user_id);
add_action('init', 'new_admin_account');

Save the change in text editor, upload it with overwriting existing document and go to logon page using new admin login details.

As the note in code snippet mentioned, after new admin user creation delete the snippet.