Automattic\WooCommerce\Internal\Utilities

Users::get_site_user_meta()public staticWC 1.0

Site-specific method of retrieving the requested user meta.

This is a multisite-aware wrapper around WordPress's own get_user_meta() and works by prefixing the supplied meta key with a blog-specific meta key.

Метод класса: Users{}

Хуков нет.

Возвращает

Разное. An array of values if $single is false. The value of meta data field if $single is true. False for an invalid $user_id (non-numeric, zero, or negative value). An empty string if a valid but non-existing user ID is passed.

Использование

$result = Users::get_site_user_meta( $user_id, $key, $single );
$user_id(int) (обязательный)
User ID.
$key(строка)
The meta key to retrieve. By default, returns data for all keys.
По умолчанию: ''
$single(true|false)
Whether to return a single value. This parameter has no effect if $key is not specified.
По умолчанию: false

Код Users::get_site_user_meta() WC 9.3.3

public static function get_site_user_meta( int $user_id, string $key = '', bool $single = false ) {
	global $wpdb;
	$site_specific_key = $key . '_' . rtrim( $wpdb->get_blog_prefix( get_current_blog_id() ), '_' );
	return get_user_meta( $user_id, $site_specific_key, true );
}