• Hi, I was having trouble with the pll_current_language function. The function below will echo helo but not the current language. Trying to determine language on login for redirect to fr or en page. Thx

    function cm_redirect_users_by_role() {
     
        $current_user   = wp_get_current_user();
        $role_name      = $current_user->roles[0];
    	
    	
    	if ( function_exists( 'pll_current_language' ) ) {
    		echo "helo";
    		$current_lang = pll_current_language();
    		echo $current_lang; exit;
    		}
    		
        if ( 'subscriber' === $role_name ) {
            wp_redirect( 'http://coda-services.com/project-upload' );
        } // if
     
    } // cm_redirect_users_by_role
    add_action( 'admin_init', 'cm_redirect_users_by_role' );
    
    }
Viewing 1 replies (of 1 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    On admin side, the “current” language is not always defined. This is not the display language (which is accessible with get_locale()). It could be equal to the language set in the admin language filter or the language of the current post or term being edited or false.

Viewing 1 replies (of 1 total)

The topic ‘Redirect based on Language’ is closed to new replies.