If you have no access to your WordPress backend and no phpMyAdmin to change your password… here is a simple and fast solution.

Note: You need a FTP connection to your server.

Open your theme functions.php and add the following code to create a new user with administrator role:

function wpb_admin_account(){
    $user = 'USERNAME';
    $pass = 'PASSWORD';
    $mail = 'USER@MAIL.COM';

    if (!username_exists($user)  && !email_exists($mail)) {
        $user_id = wp_create_user($user, $pass, $mail);
        $user = new WP_User($user_id);

add_action('init', 'wpb_admin_account');

Leave a Reply

Your email address will not be published. Required fields are marked *