after login that will redirect user role into a page


I am trying to create a hook that when a user login, it check the user role.. if the user role is jsa_contributor then it redirect into specific page. but it seems my code didn’t work.

This is the code..

function my_login_redirect($login) {
    $data_login = get_option('axl_jsa_login_wid_setup');
    $redirect_page = $data_login[0];

    $logout_redirect_page = $data_login[1];

    $current_user = get_user_by('login',$login);
    if($current_user->roles == 'jsa_contributor'){
        wp_redirect(get_permalink($redirect_page)); /* Redirect browser */

add_action('wp_login', 'my_login_redirect', 99);

does anyone have an idea about this? thanks in advance…

gadss 4 months 0 Answers 8 views 0

Leave an answer