Language Column in the Users List
Shows each user's chosen dashboard language in Users > All Users, which helps when you send emails or support in their language.
Opens WPIDE on
Code
add_filter( 'manage_users_columns', function ( $columns ) {
$columns['wpide_locale'] = __( 'Language' );
return $columns;
} );
add_filter( 'manage_users_custom_column', function ( $output, $column, $user_id ) {
if ( 'wpide_locale' !== $column ) {
return $output;
}
$locale = get_user_meta( $user_id, 'locale', true );
if ( ! $locale ) {
return '<span style="color:#646970">' . esc_html__( 'Site default' ) . '</span>';
}
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
static $names = null;
if ( null === $names ) {
$names = array( 'en_US' => 'English (United States)' );
foreach ( (array) wp_get_available_translations() as $code => $data ) {
$names[ $code ] = $data['native_name'];
}
}
return esc_html( isset( $names[ $locale ] ) ? $names[ $locale ] : $locale );
}, 10, 3 );
Notes
Users without their own choice show "Site default".
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.