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?

  • Did you confirm this code as working before you tweaked it?
    – editor
    Jan 18, 2011 at 23:00

1 Answer 1


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
  • 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, 2011 at 0:00
  • did you define the capabilities of the custom roles?
    – Bainternet
    Jan 19, 2011 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, 2011 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, 2011 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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