switch_to_user_locale

函数
switch_to_user_locale ( $user_id )
参数
  • (int) $user_id User ID.
    Required:
返回值
  • (bool) True on success, false on failure.
定义位置
相关方法
switch_to_localeget_user_localeswitch_to_blogswitch_themerestore_previous_locale
引入
6.2.0
弃用
-

switch_to_user_locale(): 这个函数暂时将WordPress网站的语言环境切换到指定用户的语言环境。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function switch_to_user_locale( $user_id ) {
/* @var WP_Locale_Switcher $wp_locale_switcher */
global $wp_locale_switcher;
if ( ! $wp_locale_switcher ) {
return false;
}
return $wp_locale_switcher->switch_to_user_locale( $user_id );
}
function switch_to_user_locale( $user_id ) { /* @var WP_Locale_Switcher $wp_locale_switcher */ global $wp_locale_switcher; if ( ! $wp_locale_switcher ) { return false; } return $wp_locale_switcher->switch_to_user_locale( $user_id ); }
function switch_to_user_locale( $user_id ) {
	/* @var WP_Locale_Switcher $wp_locale_switcher */
	global $wp_locale_switcher;

	if ( ! $wp_locale_switcher ) {
		return false;
	}

	return $wp_locale_switcher->switch_to_user_locale( $user_id );
}

常见问题

FAQs
查看更多 >