• Eklavyam

    (@eklavyam)


    Solving the problem: wp-admin, You do not have sufficient permissions to access this page.
    Hi friends,

    Recently, I had to face the most challenging wordpress problem of my life. In this post, I am going to tell you in brief as to what I finally did to solve this problem which was driving me crazy for past 5 days. My intention to share this workaround is to help others who may be facing/may face in future this problem which often frustrates a majority of wordpress users.

    The problem is : No admin access to your wordpress blog.

    Whenever you try to login to your wordpress admin, you are greeted with the following message :

    You do not have sufficient permissions to access this page.

    This is a problem which has no straightaway cause or solution. Actually it is an indication that something is wrong with your wordpress installation- either at database level or at core file’s level. In most of the cases, the frontend of the blog keeps functioning i.e. remains available to the visitors. However, the owner of the site could not log in to dashboard to do anything.
    I came across this problem when I recently moved my websites from my earlier host (Let’s call it host A) to my new host (Let’s Call it host ‘B’). As I was having a total of 8 websites on host ‘A’ (with one main site and another 7 as Addon domains), it was too much work to manually transfer the wordpress database, other files etc to the host ‘B’. So, I requested host ‘B’ to do a full Cpanel transfer for me. They readily agreed and transferred the entire Cpanel from host A to host B in a matter of hours. I changed the DNS servers of my domains from host A to host B and wait for 24 hours to complete the proper propagation.

    When all things seemed settled, I tried to log into my wordpress blog at my site for making some new posts. However, to my surprise, I was welcomed by this message: You do not have sufficient permissions to access this page.

    I googled for a probable solution for this problem and after reading some of the results, it appeared to me that this problem generally happen while transferring your wordpress blog from one host to other. The previous host may be a localhost at your PC or it may be a webhost in a server. So I took remedial steps as followed one by one :
    Please note that these solutions require an access to your phpMyadmin and MySql databases. In most of the self hosted plans this is available.

    Solution one : Often when the wordpress blog is transferred from one location (host) to other, the table prefix as mentioned in the wp-config.php files gets changed. While the name of the database tables are changed normally on their own (based on the prefix defined in wp-config.php), in some cases a few tables retained their old name.

    For example the name of the table wp_ comments may have to be changed to newprefix_comments but it does not happen on its own.
    This creates conflicts in the wordpress and hence the error.
    Further, even when all the tables have been renamed by the new prefix, a few fields inside some of the tables and their values are also required to be changed.

    Instead of repeating myself, it would be better to point you towards this excellent solution on another posts a the forum by one user:

    https://www.ads-software.com/support/topic/wp-admin-you-do-not-have-sufficient-permissions-to-access-this-page

    Unfortunately this solution does not work in my case. Since in my case, entire Cpanel was transferred as a whole, there was no question of having different table prefix. All my tables and the fields inside them have the original table prefix (wp_)

    Meanwhile, I also requested my new host (Host B) to help me resolve this issue. However, as the issue is wordpress centric, not much help could be extended by them. They only did a fresh migration of my wordpress database from my earlier host (Host A). However, even remigration of the data does not work.

    Solution two: Another solution was to create another admin user for the wordpress and login from his credentials. I followed the steps as given in this post and create a new user.

    Create a WordPress admin user with MySQL
    If you’ve ever been locked out of a WordPress installation, but have access to the database, here’s a nifty snippet to grant you administrator-level access. There are a couple of things you need to do before using this MySQL code. First, set the variables to your own information. Next, if your WordPress installation is based on a non-standard wp_ table prefix, you must find/replace ‘wp_’ with your current table prefix.

    SET @id = 99;
    SET @user = 'username';
    SET @pass = 'password';
    SET @email = 'email@ddress';
    SET @name = 'Your Name';
    
    INSERT INTO  wp_users (ID, user_login, user_pass, user_nicename, user_email, user_url, user_registered, user_activation_key, user_status, display_name) VALUES (@id, @user, MD5(@pass), @name, @email, '', '2013-06-20 00:00:00', '', '0', @name);
    INSERT INTO  wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, @id, 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
    INSERT INTO  wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, @id, 'wp_user_level', '10');
    INSERT INTO  wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (NULL, @id, 'active', '1');

    However, nothing happened. I was still getting the dreaded message of No admin access.

    Solution three: The third solution was to fix the default user role in our wordpress database. Sometimes, the value of default user roles in wordpress gets corrupted resulting in the above error. To rectify it, we need to reset the default user role. For this we need to go to the wp_options table and find the row with option_name = ‘wp_user_roles. Here we need to replace its value with the correct value. Again for brevity’s sake, I am pointing to a link wherein this solution has been explained in great detail.

    https://wp-relief.com/2011/12/01/user-roles-in-the-wordpress-database/

    Unfortunately, for me even this solution did not work.
    Final solution that worked: While my ongoing search was not fructifying, I read a suggestion somewhere of a debug mode in the wp-config.php file.

    So in my wp-config file, I changed this line:

    define('WP_DEBUG', false);

    to

    define('WP_DEBUG', true);

    Immediately after doing it, I found a displayed list of errors happening inside the WordPress installation of my blog. These error starts showing in the frontend of my blog itself and were of the following nature:

    Unexpected character in input: ' in /wp-includes/default-filters.php on line 398
    
    Notice: Constant WPINC already defined in /home2/……/public_html/blog/wp-config

    From the error message shown, it was clear that my problem was neither of any prefix in the database tables, nor of any corrupt table or of any wrong user permission in the database. It was happening because of corrupt (perhaps infected) ‘default-filters.php’ file in the wp-includes folder.

    To rectify this error, I downloaded a fresh zip download of wordpress from its main website and compared the erroneous files of my blog with the original files of the wordpress. On finding errors, I replaced the faulty file (viz. default-filters.php) with that of the main file.
    I also came to know that at my earlier webhost (host A), my wp-config website was also compromised as I found a malicious code in it pointing to an alien php file named core-load.php which was hidden inside the wp-includes folder. That’s why I was getting the ‘Constant WPINC already defined..’ error.

    I cleaned the malicious code from the wp-config file and delete the said alien file.

    The problem of insufficient access vanished the moment I restored the clean files in wordpress as mentioned above and I succeeded in accessing the admin panel of my blog.

    It is this clear that the problem of no admin access is not limited to an error in your wordpress database. It can also be caused by a malicious code in your wordpress files. I also learned that the Debug mode in wp-config.php is one of the most powerful tool for finding the most nagging problems which are extremely hard to find.

    I hope this post may be useful to some of the users facing such problem.

Viewing 1 replies (of 1 total)
  • André Klein

    (@akleines2)

    Thanks a lot for taking the time and sharing all those cases. Great job!

    My case was the WP table prefix. Although different from the one you describe, as I had renamed the WP table prefix from `wp_ to `wpc_. By setting the change back it worked again.

    To make it work with a changed prefix, apart of changing `wp_ to `wpc_. I had to add some additional changes.
    ‘wp_ -> ‘wpc_
    “wp_ -> “wpc_
    ‘_wp_ -> ‘_wpc_

    But then the widgets stopped showing up, and maybe something else broke as well; so I decided to switch all back to wp_. Strange, because I have done this process before without problems

    Best regards,
    André Klein

Viewing 1 replies (of 1 total)
  • The topic ‘Solving the problem: wp-admin, You do not have sufficient permissions to access’ is closed to new replies.