“Sorry, you are not allowed to access this page.”

When you see this kinda message, there are a few things that can go wrong, I won’t go into detailing all of them. I will be focusing precisely on one, but before I do that, let’s quickly check what could go wrong

  1. Wrong user role for the user that is signing in
  2. Upgrade to latest version of wordpress has gone wrong
  3. wp_options table got corrupted
  4. Your site is hacked
  5. Wrong file level permissions
  6. Missing role of an Administrator
  7. and gazilion others …

Let’s focus on point 6, 

The missing administrator role

This can happen because of various reasons

  1. Faulty plugin
  2. Human error
  3. Corrupt wp_options table

So let see what we can do to restore it

wp_options table have a column called option_name, execute the follow MySQL statement to see if our wp_user_roles value is present or not

This should return you a row with option_value which should be a long string. 

If above query doesn’t return anything, then check your database backup, restore it locally (not on production server) and see what value this property had

If above query returned an option value which did not list “Administrator” in the awkwardly looking JSON string, then also refer to the back and see what value you had to restore it. 

If your backup is missing, then you can temporarily use the folling query to restore access

Now try to login again, if administrator role was missing, you would’ve been redirected to /my-account page of your website or the website home page.

Couple of other points, 

Check if your admin user has administrator capabilities, 

I am assuming that your default user have an ID of 1. Check if the value of meta_value property has something like this as a value

a:1:{s:13:"administrator";b:1;}

If above is not sighted, the do this to have it added

make sure to replate REPLACE_WITH_META_ID with your meta_id that corresponds to meta_key = ‘wp_capabilities’

Also make sure that meta_key = ‘wp_user_level’ for your user has a value of 10. 

IF everthing fails 

There are several hacks that can be performed on wordpress core to allow temporary admin access to your user. I generally mess up with /wp-includes/capabilities.php 

In this file there is a function called current_user_can

I know that to the wordpress purists, above point may sound crazy, but that’s just one way of doing it.

I hope this helps

 

Apache slow time to first byte TTFB linked to slow DNS lookup [localhost]

A really brief post here I had an issue where I had a virtual domain (say jaspreetchahal.org) configured with apache virtual hosts and in my hosts file entries on my iMac (sudo vi /etc/hosts), I want this domain to resolve to 127.0.0.1 The … [Continue reading]

WordPress Fatal error: Allowed memory size of {N} bytes exhausted (tried to allocate {N} bytes)

The default allocated memory to any Wordpress site can vary on your settings either at the system level (PHP Configurations) or how you set it up in WordPress. When you get this kind of error ( Allowed memory exhausted), that means that your … [Continue reading]

Braintree\Exception\SSLCertificate with braintree_php sdk

Ok so I scratched my head around this for a while to figure out why would this happen There are several reasons The request URL was malformed. (This was ok in my case, I've logged each request and didn't see any issues) The request was an … [Continue reading]

NodeJS How to determine or check for current OS (Operating System)

There are two ways of doing it, First using the native OS module, Check out the API function available for OS module here https://nodejs.org/dist/latest-v5.x/docs/api/os.html#os_os_platform  Basically, all you have to do is to call platform() … [Continue reading]

PHP check if search engine bot

How do you check if your website is being crawled by a bot or spider, or in case you want to expose a certain section or sections of your website to the search engines which otherwise would be hidden from them as they are protected … [Continue reading]

Ionic 2+ How to access parent navController

There could potentially be scenarios when you will have something like this [crayon-5df27bb3caf32504944040/] Each of ion-nav components have their own NavController, when you try to push or pop a view, depending on the inheritance level of your … [Continue reading]

PHP: Check if Start of each word in a sentence is uppercase or any part of a word is UPPERCASE

When working with strings, occasionally we would want to check if any part of a word is uppercase or start of a word is an uppercase letter. This post provide a generic function that can be extended to match your needs. For this post I will use … [Continue reading]

How to convert a string to equivalent integer value based on ASCII codes in Javascript

Hi Guys, Here is a quick tip if you would like to convert a string into a sum of ASCII codes for all characters Function you can use For ES5: [crayon-5df27bb3cb4d2678255744/] We can do equivalent in ES6 … [Continue reading]

Hunspell with PHP on Windows – Part 1

Ok so I hear you saying, how the hell can I use Hunspell and PHP with Windows, Now the way I am going to show you isn't the only way but is a much simpler way without compiling and using binaries. What is Hunspell? Well I can re-write what's … [Continue reading]