Last active
July 15, 2016 15:59
-
-
Save azanebrain/e49fc448a28e2e92619a to your computer and use it in GitHub Desktop.
Change the user language depending on the username. This example defaults to Japanese, unless you are me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Change User Language | |
* Description: Change the language depending on the user | |
* Version: 0.1 | |
* Author: AJ Zane | |
* Author URI: http://AJZane.com | |
* License: GPL2 | |
*/ | |
add_filter( 'locale', 'change_user_lang' ); | |
function change_user_lang( $locale ) { | |
//Define the user list using english | |
$users_list_en = array( | |
"ajzane" | |
); | |
if ( in_array( wp_get_current_user()->user_login, $users_list_en , true ) ) { | |
return 'en-US'; //or whatever you want your native language to be | |
} else { | |
return 'ja'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment