WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have used this function below for a while now on normal WordPress installs.

It simply blocks users with specific user roles, and redirects them to the home page of the site.

function wpse23007_redirect(){
  if( is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') || current_user_can('media') ) ){

But when I install this on a sub theme in my WordPress Multisite, even though I am a superuser, it is blocking me from the dashboard of my sub theme.

Can anyone help me understand why this is and how to change the above so it doesn't block me?

share|improve this question
up vote 1 down vote accepted

All your role checks are relative to the user roles in the sub site in which I assume you are not a user. You should also check for is_super_admin()

  if( !is_super_admin() && (is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') || current_user_can('media') ) ) ){
share|improve this answer
Works perfect thank you! – Joshc Feb 6 '13 at 9:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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