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.
Return
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 $key is not specified.
Default: false
Users::get_site_user_meta() Users::get site user meta code 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 ); }