Guide to creating WordPress Admin account using function.php file.

Hướng dẫn tạo tài khoản Admin Wordpress thông qua file function.php

This content provides instructions on how to create a new WordPress Admin account if you have forgotten your password. By accessing the function.php file in your WordPress theme through the VPS file manager, you can insert specific code to add a new admin account. After saving the changes, you can log in to your WordPress website with the newly created account. This process involves entering a new username, password, and email address for the admin account. By following these steps, you can regain access to your WordPress website without knowing the original Admin password.

Are you using Minivps WordPress VPS to manage your WordPress websites, but forgot your Admin password and can’t access your account? No worries, we’ve got you covered. Here’s how you can create a new WordPress Admin account using the function.php file of your WordPress theme.

Table of Contents

Step 1:

Firstly, navigate to the VPS file manager and locate the theme folder you are currently using. For example, if your theme is named "theme1", the path to access the file will be:

/wp-content/themes/theme1/function.php

Step 2:

Next, open the function.php file and add the following code snippet right after the opening PHP tag:

function add_admin_acct(){
    $login = 'myacct1';
    $passw = 'mypass1';
    $email="myacct1@mydomain.com";

    if ( !username_exists( $login ) && !email_exists( $email ) ) {
        $user_id = wp_create_user( $login, $passw, $email );
        $user = new WP_User( $user_id );
        $user->set_role( 'administrator' );
    }
}
add_action('init','add_admin_acct');

Make sure to replace the placeholders with your desired credentials:

See also  Complete guide to Advanced Custom Fields usage.

Step 3:

Save the file, then head to the WordPress login page at domain.com/wp-login.php and log in using the newly created admin account. That’s it! Good luck with your WordPress endeavors.

Rate this post

Related posts