Automattic\WooCommerce\Internal\Utilities
Users::get_site_user_meta
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.
Method of the class: Users{}
No Hooks.
Returns
Mixed. 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.
Usage
$result = Users::get_site_user_meta( $user_id, $key, $single );
- $user_id(int) (required)
- User ID.
- $key(string)
- The meta key to retrieve. By default, returns data for all keys.
Default:'' - $single(true|false)
- Whether to return a single value. This parameter has no effect if
$keyis not specified.
Default: true (WordPress'sget_user_meta()defaults this to false)
Users::get_site_user_meta() Users::get site user meta code WC 10.7.0
public static function get_site_user_meta( int $user_id, string $key = '', bool $single = true ) {
global $wpdb;
$site_specific_key = $key . '_' . rtrim( $wpdb->get_blog_prefix( get_current_blog_id() ), '_' );
return get_user_meta( $user_id, $site_specific_key, $single );
}