Automattic\WooCommerce\Internal\Utilities

Users::update_site_user_meta()public staticWC 1.0

Site-specific means of updating user meta.

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

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

Хуков нет.

Возвращает

int|true|false. Meta ID if the key didn't exist, true on successful update, false on failure or if the value passed to the function is the same as the one that is already in the database.

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

$result = Users::update_site_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
$user_id(int) (обязательный)
User ID.
$meta_key(строка) (обязательный)
Metadata key.
$meta_value(разное) (обязательный)
Metadata value. Must be serializable if non-scalar.
$prev_value(разное)
Previous value to check before updating. If specified, only update existing metadata entries with this value. Otherwise, update all entries.
По умолчанию: ''

Код Users::update_site_user_meta() WC 9.3.3

public static function update_site_user_meta( int $user_id, string $meta_key, $meta_value, $prev_value = '' ) {
	global $wpdb;
	$site_specific_key = $meta_key . '_' . rtrim( $wpdb->get_blog_prefix( get_current_blog_id() ), '_' );
	return update_user_meta( $user_id, $site_specific_key, $meta_value, $prev_value );
}