get_user_locale( int|WP_User $user_id )
Retrieves the locale of a user.
Description
If the user has a locale set to a non-empty string then it will be returned. Otherwise it returns the locale of get_locale().
Parameters
- $user_id
-
(Required) User's ID or a WP_User object. Defaults to current user.
Return
(string) The locale of the user.
Source
File: wp-includes/l10n.php
function get_user_locale( $user_id = 0 ) {
$user = false;
if ( 0 === $user_id && function_exists( 'wp_get_current_user' ) ) {
$user = wp_get_current_user();
} elseif ( $user_id instanceof WP_User ) {
$user = $user_id;
} elseif ( $user_id && is_numeric( $user_id ) ) {
$user = get_user_by( 'id', $user_id );
}
if ( ! $user ) {
return get_locale();
}
$locale = $user->locale;
return $locale ? $locale : get_locale();
}
Related
Uses
Uses | Description |
---|---|
wp-includes/l10n.php: get_locale() |
Retrieves the current locale. |
wp-includes/pluggable.php: wp_get_current_user() |
Retrieve the current user object. |
wp-includes/pluggable.php: get_user_by() |
Retrieve user info by a given field |
Used By
Used By | Description |
---|---|
wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::export_preview_data() |
Exports data in preview after it has finished rendering so that partials can be added at runtime. |
wp-includes/general-template.php: get_bloginfo() |
Retrieves information about the current site. |
wp-includes/script-loader.php: wp_default_scripts() |
Register all ClassicPress scripts. |
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::prepare_item_for_response() |
Prepares a single user output for response. |
wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::export_preview_data() |
Communicates the sidebars that appeared on the page at the very end of the page, and at the very end of the wp_footer, |
wp-includes/l10n.php: load_default_textdomain() |
Load default translated strings based on locale. |
wp-includes/l10n.php: load_plugin_textdomain() |
Loads a plugin’s translated strings. |
wp-includes/l10n.php: load_muplugin_textdomain() |
Load the translated strings for a plugin residing in the mu-plugins directory. |
wp-includes/l10n.php: load_theme_textdomain() |
Load the theme’s translated strings. |
wp-includes/l10n.php: _get_path_to_translation_from_lang_dir() |
Gets the path to a translation file in the languages directory for the current locale. |
wp-includes/pluggable.php: wp_new_user_notification() |
Email login credentials to a newly-registered user. |
wp-includes/user.php: wp_update_user() |
Update a user in the database. |
wp-includes/class-wp-theme.php: WP_Theme::sort_by_name() |
Sorts themes by name. |
wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_preview_settings() |
Print JavaScript settings for preview frame. |
wp-includes/class-wp-locale-switcher.php: WP_Locale_Switcher::__construct() |
Constructor. |
wp-includes/class-wp-locale-switcher.php: WP_Locale_Switcher::switch_to_locale() |
Switches the translations according to the given locale. |
wp-includes/ms-functions.php: update_network_option_new_admin_email() |
Send a confirmation request email when a change of network admin email address is attempted. |
wp-includes/ms-functions.php: wpmu_welcome_notification() |
Notify a user that their blog activation has been successful. |
wp-includes/ms-functions.php: wpmu_welcome_user_notification() |
Notify a user that their account activation has been successful. |
wp-includes/ms-functions.php: wpmu_signup_blog_notification() |
Send a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked. |
wp-includes/ms-functions.php: wpmu_signup_user_notification() |
Send a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked. |
wp-includes/class-wp-editor.php: _WP_Editors::editor_settings() | |
wp-includes/class-wp-editor.php: _WP_Editors::get_mce_locale() | |
wp-includes/functions.php: wp_auth_check_html() |
Output the HTML that shows the wp-login dialog when the user is no longer logged in. |
wp-admin/includes/misc.php: update_option_new_admin_email() |
Send a confirmation request email when a change of site admin email address is attempted. |
wp-admin/includes/template.php: iframe_header() |
Generic Iframe header for use with Thickbox |
wp-admin/includes/plugin-install.php: plugins_api() |
Retrieves plugin installer pages from the ClassicPress.net Plugins API. |
wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::prepare_items() | |
wp-admin/includes/theme.php: themes_api() |
Retrieves theme installer pages from the ClassicPress.net Themes API. |
wp-admin/includes/import.php: wp_get_popular_importers() |
Returns a list from ClassicPress.net of popular importer plugins. |
wp-admin/includes/dashboard.php: wp_dashboard_browser_nag() | |
wp-admin/includes/dashboard.php: wp_dashboard_cached_rss_widget() |
Checks to see if all of the feed url in $check_urls are cached. |
wp-admin/includes/dashboard.php: wp_dashboard_rss_control() |
The RSS dashboard widget control. |
Changelog
Version | Description |
---|---|
WP-4.7.0 | Introduced. |