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 need to have users land on a specific admin page based on user role in WP 3.0 multi-site enabled. I found this

function fb_redirect_2() {

    if ( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) ) {
        if ( function_exists('admin_url') ) {
            wp_redirect( admin_url('edit-comments.php') );
        } else {
            wp_redirect( get_option('siteurl') . '/wp-admin/' . 'edit-comments.php' );
if ( is_admin() )
    add_action( 'admin_menu', 'fb_redirect_2' );

And changed

if ( is admin() ) 


if ( current_user_can('edit_posts') )

but this isn't working...

Any Suggestions?

share|improve this question
Did you confirm this code as working before you tweaked it? – editor Jan 18 '11 at 23:00

you need to populate the


function before using it using


so try this code:

add_action( 'admin_menu', 'fb_redirect_2' );

function fb_redirect_2(){
    if ( current_user_can('edit_posts')){
    //redirect here
share|improve this answer
Thanks! This worked great. Obviously I know enough PHP to be dangerous;-) I am also finding this works for WP standard roles, however on the custom roles defined in functions.php it totally ignores the whole thing??? Anyone have any idea - I'm off to search... – Ann Jan 19 '11 at 0:00
did you define the capabilities of the custom roles? – Bainternet Jan 19 '11 at 0:29
yes. in the functions.php file It seems to be dependent on what happens first - the role declaration or the redirect rule? – Ann Jan 19 '11 at 17:34
Actually if user tries to log in at main domain, the rule is ignored because of the role specification for that site... works fine when they log in at maindomain.com/theirsite. I am now looking for a way to have the user re-directed to their member blog backend... if any body has an suggestions I would gladly accept! Meanwhile searching... – Ann Jan 21 '11 at 19:44

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.