Title: Admin access lost
Last modified: September 11, 2022

---

# Admin access lost

 *  Resolved [Deceiver1752](https://wordpress.org/support/users/gazanowsky/)
 * (@gazanowsky)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/)
 * Hi,
 * I have a website I created last year. I access the dashboard once in a while 
   and recently I figured out that I lost my access to the admin dashboard.
 * I can connect myself through the wp-login.php page with the same ID and password.
   But the dashboard looks like I’m a subscriber or let’s say, a “standard user”.
 * I checked on my SQL database and I don’t have any other user registered. I also
   followed a tutorial on how to create a new admin user directly via the Phpmyadmin
   but nothing seems to work.
 * Any idea of what happened ? How can I fix that really annoying bug ?
 * Thank you,
 * Guillaue

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Moderator [threadi](https://wordpress.org/support/users/threadi/)
 * (@threadi)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-15998944)
 * If you have already followed a tutorial on this, you have missed some point described
   in it. Because you not only have to create the user, but also give him permissions.
   Which tutorial was it? Maybe then you can see what is missing.
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-15999255)
 * Hi there, the simple thing is to follow the instructions below:
 *     ```
       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');
       ```
   
 * add the above code to the active theme’s functions.php file and replace the username,
   password, and email. this will create a new administrator account on the site
   and then you will be able to login to the site using the new login credentials
   that you just updated on the functions.php file.
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-15999256)
 * after logged in don’t forget to remove the code that you added to the functions.
   php file
 *  Thread Starter [Deceiver1752](https://wordpress.org/support/users/gazanowsky/)
 * (@gazanowsky)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16019385)
 * [@threadi](https://wordpress.org/support/users/threadi/)
    If you have already
   followed a tutorial on this, you have missed some point described in it. Because
   you not only have to create the user, but also give him permissions. Which tutorial
   was it? Maybe then you can see what is missing.
 * I don’t remember which tutorial I’ve been through. But there were 2 steps:
    1.
   Create a new user in the wp-user database table. 2. Attribute a role to this 
   user in the wp-metauser table It didn’t worked, unfortunately.
 * [@sshahadatgsm](https://wordpress.org/support/users/sshahadatgsm/) Your code 
   worked perfectly ! Thank you.
 * My ex-admin user were switched into a subscriber role. I don’t know why.
 * Topic solved !
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16019398)
 * [@gazanowsky](https://wordpress.org/support/users/gazanowsky/) That’s great! 
   I’m happy to hear that my code is worked for you!
 *  [paulbenter](https://wordpress.org/support/users/paulbenter/)
 * (@paulbenter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16284878)
 * Hi,
 * I have a very similar problem, but the solution didn’t work for me.
 * The website I manage has a few admin users, but while all of them can still log
   in normally, once they are, none of them can access the dashboard. I had a look
   in the SQL database and all of them still have administrator privileges.
 * I have tried creating a new admin user through PhpMyAdmin, I tried the above 
   code in the functions.php, tried deactivating all the plugins by renaming in 
   the plugins folder but nothing seems to work. It creates a new admin user every
   time, but the new users still have the same issue as the ones that existed before.
 * I have run out of ideas to try to resolve the issue, so any suggestions would
   be greatly appreciated.
 * Thank you,
 * Paul
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16284921)
 * Hi [@paulbenter](https://wordpress.org/support/users/paulbenter/) if none of 
   the above methods are not working then I can look at it for you! If you want 
   then I can help you with this!
 * Let me know if you need my help with this
 *  [paulbenter](https://wordpress.org/support/users/paulbenter/)
 * (@paulbenter)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16285465)
 * Hi [@sshahadatgsm](https://wordpress.org/support/users/sshahadatgsm/),
 * Do you have an idea, what the issue might be? In the meantime, I’ve tried renaming
   the .htaccess file and logging in, and looked through the wp-config, -login, 
   and the themes functions.php files, but nothing seems to be out of the ordinary,
   and it still doesn’t work.
 * Best regards,
    Paul
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16285484)
 * No idea right now! I can say something after checking everything by myself
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16285985)
 * [@sshahadatgsm](https://wordpress.org/support/users/sshahadatgsm/) I’ve deleted
   your offer to connect with another user off-site. I’m am 100% sure you mean well
   but please _never ask for credentials on these forums._
 * [https://wordpress.org/support/guidelines/#the-bad-stuff](https://wordpress.org/support/guidelines/#the-bad-stuff)
 * Now for the why: The internet is a wonderful place full of very nice people and
   a few very bad ones. I’m sure everyone here is very nice however, by giving some
   ones keys to your house you are trusting they wont steal anything. Likewise the
   person who takes the keys is now responsible for the house FOREVER.
 * If something was to go wrong, then you the author may well legally become liable
   for damages, which they would not normally have been as their software is provided
   without warranty.
 * **Please be aware that repeatedly asking for credentials will result in us escalating
   this to the plugins team.**
 * It’s never necessary to do that. Here’s why.
 * There are many ways to get information you need and accessing the user’s site
   is not one of them. That’s going too far.
    - Ask for a link to the [https://pastebin.com/](https://pastebin.com/) or [https://gist.github.com](https://gist.github.com)
      log of the user’s web server error log.
    - Ask the user to create and post a link to their `phpinfo();` output.
    - Ask the user to install the [Health Check plugin](https://wordpress.org/support/plugin/health-check/)
      and get the data that way.
    - Walk the user through [enabling WP_DEBUG and how to log that output to a file and how to share that file.](https://codex.wordpress.org/WP_DEBUG#WP_DEBUG_LOG_and_WP_DEBUG_DISPLAY)
    - Walk the user through basic troubleshooting steps such and disabling all other
      plugins, clear their cache and cookies and try again.
    - Ask the user for the step-by-step on how they can reproduce the problem.
 * You get the idea.
 * Volunteer support is not easy. But these forums need to a safe place for all 
   users, experienced or new. Accessing their system that way is a short cut that
   will get you into real trouble in these forums.
 *  [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * (@sshahadatgsm)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16286226)
 * [@sterndata](https://wordpress.org/support/users/sterndata/) Thank you, I’ll 
   keep this in my mind.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Admin access lost’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 5 participants
 * Last reply from: [Shahadat](https://wordpress.org/support/users/sshahadatgsm/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/admin-access-lost/#post-16286226)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
