Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 )  
        return;

    if ( current_page('is_admin()') & !current_user_can('delete_users') ) {
            wp_redirect( site_url( '/login/dashboard/' ) );
            exit();
    }
}
share|improve this question

1 Answer 1

up vote 0 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

 
discard

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.