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 created a common custom dashboard for my users located at "http://website.com/login/dashboard/"

I'm trying to redirect users to that custom dashboard only if they are NOT admins & if the page IS http://www.website.com/login/wp-admin/

The redirection function I have is:

add_action( 'admin_init', 'redirect_so_15396771' );

function redirect_so_15396771()
    if ( defined( 'DOING_AJAX' ) && DOING_AJAX )  

    if ( current_page('is_admin()') & !current_user_can('delete_users') ) {
            wp_redirect( site_url( '/login/dashboard/' ) );
share|improve this question
up vote 1 down vote accepted

You can test for roles with current_user_can():

if ( is_admin() && !current_user_can('administrator') ) {
    // redirect
share|improve this answer
thanks this worked like a charm! – user1823055 Mar 14 '13 at 23:16

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.