Automattic\WooCommerce\Internal\Admin

WCAdminUser::get_user_data_field()public staticWC 1.0

Helper to retrive user data fields.

Migrates old key prefixes as well.

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

No Hooks.

Return

Mixed. The user field value.

Usage

$result = WCAdminUser::get_user_data_field( $user_id, $field );
$user_id(int) (required)
User ID.
$field(string) (required)
Field name.

Code of WCAdminUser::get_user_data_field() WC 7.1.0

public static function get_user_data_field( $user_id, $field ) {
	$meta_value = get_user_meta( $user_id, 'woocommerce_admin_' . $field, true );

	// Migrate old meta values (prefix changed from `wc_admin_` to `woocommerce_admin_`).
	if ( '' === $meta_value ) {
		$old_meta_value = get_user_meta( $user_id, 'wc_admin_' . $field, true );

		if ( '' !== $old_meta_value ) {
			self::update_user_data_field( $user_id, $field, $old_meta_value );
			delete_user_meta( $user_id, 'wc_admin_' . $field );

			$meta_value = $old_meta_value;
		}
	}

	return $meta_value;
}