locked out of Wordpress dashboard Print

  • 2

If you are locked out of your WordPress administrator area but still have access to your filesystem you can make a new user to access your website. 

Navigate to your functions.php file at: 

/yoursite.com/wp-content/themes/your-current-theme/functions.php

and then add this code to the bottom of the file:

/yoursite.com/wp-content/themes/your-current-theme/functions.php

function wpb_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user )  && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
add_action('init','wpb_admin_account');
 
Anew user will be created and you can login as usual. 

Was this answer helpful?

« Back