Skip to:
Content
Pages
Categories
Search
Top
Bottom

On login redirect to users profile page based on language

Viewing 5 replies - 1 through 5 (of 5 total)

  • Henry Wright
    Moderator

    @henrywright

    How does the user select the language?


    fugu78
    Participant

    @fugu78

    Hi Henry,

    With a language switcher plugin

    Cheers


    Henry Wright
    Moderator

    @henrywright

    In that case you’d base your condition on the chosen language value. Here’s an example:

    // You'll get $lang from your language switcher plugin.
    
    if ( $lang == 'thai' ) {
        // Redirect to Thai
    } else {
        // Redirect to English
    }

    fugu78
    Participant

    @fugu78

    I apologize but i am not sure where to add that line of code to the below redirect code:

    add_filter("login_redirect","bpdev_redirect_to_profile",10,3);
     
    function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
    {
    if(empty($redirect_to_calculated))
    $redirect_to_calculated=admin_url();
     
    /*if the user is not site admin,redirect to his/her profile*/
    if(!is_site_admin($user->user_login))
    return bp_core_get_user_domain($user->ID );
    else
    return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/
     
    }
    
    add_filter('logout_url',"bpdev_logout_url",100,2);
    function bpdev_logout_url( $logout_url, $redirect) {
    //simply ignore the redirect and set it to the main domain
    //let us check for buddyopress,if yes,let us get the bp root domain right ?
    if(function_exists("bp_core_get_root_domain"))
    $redirect=bp_core_get_root_domain();
    else
    $redirect = get_blog_option( SITE_ID_CURRENT_SITE, 'siteurl' );
    
    $args = array( 'action' => 'logout' );
    if ( !empty($redirect) ) {
    $args['redirect_to'] = $redirect;
    }
    
    $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
    $logout_url = wp_nonce_url( $logout_url, 'log-out' );
    
    return $logout_url;
    }
    
    ?>

    Henry Wright
    Moderator

    @henrywright

    The snippet I wrote wasn’t designed for copy and pasting. You’d need to modify it to your requirements using PHP.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘On login redirect to users profile page based on language’ is closed to new replies.
Skip to toolbar