My site's contributors are successfully registered.

However, when they log in I want them to be directed directly to the home page of the site on not to their profile, because they do not need it.

Is this possible?

Thank you.


Yes this is possible. You can use the login_redirect filter to do this.

Use the code below in your active theme's functions.php file.

function my_login_redirect( $redirect_to, $request, $user ) {
    //is there a user to check?
    global $user;
    if( isset( $user->roles ) && is_array( $user->roles ) ) {
        //check for contributors
        if( in_array( "contributor", $user->roles ) ) {
            // redirect them to the home page $home_url should contain the home page url
            return $home_url;
        } else {
            return $redirect_to;
    } else {
        return $redirect_to;
add_filter("login_redirect", "my_login_redirect", 10, 3);
| improve this answer | |
  • Thanks, does this work the same for role: Subscriber? – p.a. Nov 12 '13 at 11:47
  • yes it works the same way, just replace the role accordingly like if( in_array( "subscriber", $user->roles ) ) { . – Maruti Mohanty Nov 12 '13 at 11:58
  • what do you mean by "it needed some time to take affect?" – Maruti Mohanty Nov 12 '13 at 13:35
  • It wasnt immediately executed as such on our web server. Maybe due to caching reasons. – p.a. Nov 12 '13 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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