Loading...

Noah Meyhin

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Custom redirect after login based on user role #10004146
    Noah Meyhin
    Participant

    Hello,

    thank you for your quick reply.

    Following your advice, I’ve tried to add this snippet, but apparently it doesn’t work :

    add_action(‘wp_login’,’myCustomLoginHook’, 10, 2);
    function myCustomLoginHook($username,$userObject){
    $role_name = $userObject->roles[0];
    if ( ‘aaa’ == $role_name ) {
    wp_redirect( ‘http://www.mysite.com/aaa’ );
    exit;
    }
    elseif ( ‘bbb’ == $role_name ) {
    wp_redirect( ‘http://www.mysite.com/bbb’ );
    exit;
    }
    elseif( ‘ccc’ == $role_name ) {
    wp_redirect( ‘http://www.mysite.com/ccc’ );
    exit;
    }
    }

    It doesn’t work better if I use the piereg_user_login_before_redirect_hook
    Do your have any idea of what the problem might be ?

    Thanks again for your precious help !

    Noah

Viewing 1 post (of 1 total)