Ok, the following scenario:

We received a wordpress project from a customer. The customer does not have administrator access to the backend. The former developer of the project is no longer available and the password for the database is not known. The only access is the connection to the FTP server.

How can you still get full access to WordPress Backend?

We only need to add the following lines to the functions.php in the activated theme:

add_action('init', function (){
    $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);

After that, the website just has to be called up. The corresponding user is thus automatically created in the database.

Leave a Reply