Skip to content

Instantly share code, notes, and snippets.

@azanebrain
Last active July 15, 2016 15:59
Show Gist options
  • Save azanebrain/e49fc448a28e2e92619a to your computer and use it in GitHub Desktop.
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
<?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