Support » Developing with WordPress » “edit_themes” not set for Administrators in 5.8.1?

  • I use the code posted in the following solution to enable maintenance mode but still allow Administrators access:
    Maintance (sic) mode with accessible landing page
    however this code is not working under WordPress 5.8.1 and after a bit of digging I find it is because current_user_can('edit_themes') is returning false. I was able to get the code working by simply changing to 'switch_themes' but this looks like a bug to me as 'edit_themes' is documented as “Y” for Administrators (with the caveat of only for Single Sites – which mine is):
    I have checked, I am logged in as an Administrator and is_multisite() returns false also…

    • This topic was modified 3 weeks, 4 days ago by FixItDik.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    That code works with “edit_themes” on my site. Are you sure your user really has the capability? Can you access the theme editor? If others cannot replicate your issue, it’s likely not a general WP bug but something unique about your site.

    Thread Starter FixItDik


    Hmmm – if that’s the case I will dig deeper – but I have done nothing special on the site, it simply ticks over so I can’t think why that capability would have been removed from my user. The only thing to change for months is the version of PHP and WordPress but I’ll have a deeper dig, thank you.

    Moderator bcworkz


    There are a few roles and capabilities plugins that will let you easily assign the capability to any role regardless if it should have been there or not.

    Any theme or plugin you may have had in the past could have possibly removed it. It may not make sense to do so, but it’s possible all the same. One of many reasons why we should be very careful from where we source themes and plugins.

    Also, a theme or plugin can alter what current_user_can() returns regardless of if it’s correct or not. If this is what’s happening, selectively switch themes and deactivate plugins to narrow down the cause.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.