Automattic\WooCommerce\Internal\Admin

WCAdminUser::register_user_data()publicWC 1.0

Registers WooCommerce specific user data to the WordPress user API.

Method of the class: WCAdminUser{}

No Hooks.

Return

null. Nothing (null).

Usage

$WCAdminUser = new WCAdminUser();
$WCAdminUser->register_user_data();

WCAdminUser::register_user_data() code WC 9.3.3

public function register_user_data() {
	register_rest_field(
		'user',
		'is_super_admin',
		array(
			'get_callback' => function( $user ) {
				if ( ! isset( $user['id'] ) || 0 === $user['id'] ) {
					return false;
				}

				return is_super_admin( $user['id'] );
			},
			'schema'       => null,
		)
	);
	register_rest_field(
		'user',
		'woocommerce_meta',
		array(
			'get_callback'    => array( $this, 'get_user_data_values' ),
			'update_callback' => array( $this, 'update_user_data_values' ),
			'schema'          => null,
		)
	);
}