Markadler
New member
- Joined
- Jun 14, 2016
- Messages
- 17
- Points
- 0
If you're using Wordpress on a shared or a VPS to run your websites, but for some reasons, you forgot your Admin password and you could not login to WP admin page.
Following these instructions to create an Admin account via function.php file in your theme folder.
Step 1:
In the file manager of your hosting, access to theme folder that you are using.
For example, you are using wordpress theme called: mytheme then the path we need to use is:
/wp-content/themes/mytheme/function.php
Step 2:
Edit function.php file and insert the following code
(Insert after tag the <?php)
username: you want to create a new admin username
yourpassword: it's your password
youremailaddress: Email of admin account
Step 3:
Save the file, access the login page on your Wordpress site, example.com/wp-admin/ and login with your new account just created
Good luck!
Following these instructions to create an Admin account via function.php file in your theme folder.
Step 1:
In the file manager of your hosting, access to theme folder that you are using.
For example, you are using wordpress theme called: mytheme then the path we need to use is:
/wp-content/themes/mytheme/function.php
Step 2:
Edit function.php file and insert the following code
(Insert after tag the <?php)
Code:
function add_admin_acct(){
$login = 'username';
$passw = 'yourpassword';
$email = 'youremailaddress;
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');
yourpassword: it's your password
youremailaddress: Email of admin account
Step 3:
Save the file, access the login page on your Wordpress site, example.com/wp-admin/ and login with your new account just created
Good luck!