How to Force Admin to English after Auto Translations
If your site is in a different language other than English, and you have used WordPress' auto translations process - you may have noticed that this translates the MemberPress admin screens even if the admin user's language is set to English. This issue has to do with the way WordPress sets the locale.
To force English Only on the Admin screen for either all users with access to the admin screens or for just individual users - use the process below. You will need access to the files on your server either through CPanel, FTP/SFTP, or a file management plugin.
Note: This solution is formulated from information and code found here: https://developer.wordpress.org/reference/hooks/locale/
- In wp-content/plugins create a folder and call it english-only-admin
- In the new folder create a file named english-only-admin.php
- To force English for all admin users, copy the code from here and paste it in the file: https://developer.wordpress.org/reference/hooks/locale/#comment-content-1826
If you want to only force the language for specific users used this version of the code instead. Replace ### with the user id of the admin user, or a comma-separated list of user ids.
<?php /* Plugin Name: English Only Admin Plugin URI: http://your-domain.com Description: Force English (en_US) in the WordPress Admin Version: 1.0 Author: You Author URI: http://your-domain.com Text Domain: englishonlyadmin */ // prevent direct access if ( ! defined( 'WPINC' ) ) { die; } if ( ! function_exists( 'uniquePrefix_force_english_only_admin' ) ) { /** * Override locale for admin to force English (en_US). * * @param string $locale Current locale. * * @return string English (en_US) locale if in Admin, configured locale otherwise. */ function uniquePrefix_force_english_only_admin( $locale ) { $english_users = array( ### ); //REPLACE ### with the user id, or a comma seperated list of user ids // detect when we are in the admin dashboard and force english if ( is_admin() ) { $u = get_current_user_id(); if( $u && in_array( $u, $english_users ) ) { $locale = 'en_US'; } } return $locale; } add_filter( 'locale', 'uniquePrefix_force_english_only_admin', 1, 1 ); }
- Save the file
- Go to the WordPress Dashboard -> Plugins screen
- Activate the English Only Admin plugin