I'd like to force a user to a specific page upon login based on their role using

if ( current_user_can('contributor') )

and the main login function

function wp_loginout($redirect = '', $echo = true) {
    if ( ! is_user_logged_in() )
        $link = '<a href="' . esc_url( wp_login_url(get_permalink()) ) . '">' . __('Log in') . '</a>';
    else
        $link = '<a href="' . esc_url( wp_logout_url(get_permalink()) ) . '">' . __('Log out of account') . '</a>';

    if ( $echo )
        echo apply_filters('loginout', $link);
    else
        return apply_filters('loginout', $link);
}

I've tried a number of combinations and seem to be failing. Any help would be appreciated.

link|improve this question

feedback

1 Answer

up vote 4 down vote accepted

filter login_redirect:

function my_login_redirect_contributors() {
  if ( current_user_can('contributor') ){
      return 'url-to-redirect-to';
  }
}

add_filter('login_redirect', 'my_login_redirect_contributors');
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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