Title: Redirect based on Language
Last modified: October 17, 2016

---

# Redirect based on Language

 *  [jules22](https://wordpress.org/support/users/jules22/)
 * (@jules22)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/redirect-based-on-language/)
 * 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](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/redirect-based-on-language/#post-8315378)
 * 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.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Chouby](https://wordpress.org/support/users/chouby/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/redirect-based-on-language/#post-8315378)
 * Status: not resolved