1. Home
  2. FAQ
  3. How to fix Administrator locked out of backend?

How to fix Administrator locked out of backend?

Sometimes your account as Admin get stuck, because you as admin, subscribe to a membership level, or Add yourself as a Vendor.




In order to solve this problem, you can create a new Admin Account, by pasting this code in functions.php in your wyzi theme, and then visiting your website as this from a new browser:

www.yourwebsite.com/?force_admin_login=1

This way a new Admin account will be created, and do not forget to remove this code once you finish.

Make sure to change Admin_username, password & youremail@gmail.com to your data. You may need to choose a new email you did not register an account previously on your website.




function force_admin_login() {
if ( ! empty( $_REQUEST['force_admin_login'] ) ) {
$r = wp_create_user( 'Admin_username', 'password', 'youremail@gmail.com' );
if ( ! is_wp_error( $r ) ) {
$user = get_userdata( $r );
$user->set_role( 'administrator' );
if(function_exists('grant_super_admin'))
grant_super_admin($user->ID);
wp_set_auth_cookie( $user->ID );
wp_redirect( admin_url() );
exit;
} else {
wp_die( "Failed creating admin user.\n" . $r->get_error_message() );
}
}
}
add_action( 'init', 'force_admin_login' );




Was this article helpful to you? Yes No