0

Hi I have the following issue:

I am the admin of a WordPress/WooCommerce shop that has been around for a while. As of today, when I try to log into Word Press as admin I either don't get access to the wp-admin (login) page at all OR I do get access, I enter my username and password and get logged in BUT as common customer (it is a WooCommerce shop) and with no access to the dashboard. When I can't access the /wp-admin login screen - that is where I should write username and password - I get a message that I don't have sufficient permissions to see the page. I get the message before entering username and password meaning that I don't have permissions to see the login screen, not the admin dashboard. When I once in a while can log in, I see the website frontend, without the admin toolbar at the top. I am using Chrome browser, XStore theme, and Woocommerce - and a lot of small plugins.

The website works and looks fine from the outside - and from the inside when logged in as a customer. It is important to note that I did update a few plugins a few days ago and have added products. Other than that there haven't been other changes recently.

I have tried:

  1. Renaming the plugin folder from cPanel
  2. Replacing .htaccess file with an older version
  3. Renaming the plugins one by one
  4. Removing cookies, using Incognito browser, using another device
  5. Removing the IP blocking I have in .htaccess

I haven't tried to change password as my password seems to work - not as an admin though.

What can I do?

2
  • Is this new or has your user never been able to login as admin? Are you sure this is an admin account? – rudtek Feb 26 at 15:56
  • The user has always been the only admin and the website isn't new. And it should be admin account - as long as the website isn't hijacked and someone has changed it. Can I check account credentials from php my admin? – Diana D Jensen Feb 26 at 16:05
1

You can check the user credentials in phpmyadmin by looking in the _usermeta table for a the meta_key column entry called wp_capabilities. Since you only have one user it will be the only entry. If you have more than one user, I'd guess you're the user with ID 1 so match wp_capabilities column with user_id column entry "1" and see if the meta_value shows administrator. It's serialized data so it will likely look like this: a:1:{s:13:"administrator";b:1;}.

If that is not the entry there, you can always replace the meta with the above line and try signing in. You should be admin at that point.

If you need to add a new user all together there are 2 easy ways to do this:

wp-CLI : wp user create newusername newuseremail --role=administrator --user_pass="newuserpass" --first_name=newuserfirst --last_name=newuserlast

Replace the newuser variables with your own info...

If you don't have wp-CLI or are not sure how to use it, you can add this function to your theme's functions.php and load the site once. It will create the user. Please make sure to remove this code after!!!

function rt_admin_account(){
  $user = '';  //put username here
  $pass = ''; //put pw here
  $email = ''; //put email here
  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','rt_admin_account');

this creates a new user if that user doesn't exist. If it doesn't work change the username to something new and use a different email.

2
  • I can see your point @rudtek and I tried looking into it. But it looks weird when I check the wp_usermeta. I can only see two entries with user_id 1 (which I assume is me the admin) but I can see a gozillion of entries for other users. The only entries for user_id 1 are session_tolkens and wc_last_active. There is nothing else on user_id 1. That shouldn't be like this I guess? – Diana D Jensen Feb 26 at 16:51
  • that would be the problem. I'll post code to add to add a new user. are you comfortable with wp-cli? – rudtek Feb 26 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.