Automattic\WooCommerce\Admin\API

Options::user_has_permission()publicWC 1.0

Check if the user has permission given an option name.

Method of the class: Options{}

No Hooks.

Return

true|false.

Usage

$Options = new Options();
$Options->user_has_permission( $option, $request, $is_update );
$option(string) (required)
Option name.
$request(WP_REST_Request) (required)
Full details about the request.
$is_update(true|false)
If the request is to update the option.
Default: false

Options::user_has_permission() code WC 8.7.0

public function user_has_permission( $option, $request, $is_update = false ) {
	$permissions = $this->get_option_permissions( $request );

	if ( isset( $permissions[ $option ] ) ) {
		return $permissions[ $option ];
	}

	// Don't allow to update options in non-production environments if the option is not whitelisted. This is to force developers to update the option permissions when adding new options.
	if ( 'production' !== wp_get_environment_type() ) {
		return false;
	}

	wc_deprecated_function( 'Automattic\WooCommerce\Admin\API\Options::' . ( $is_update ? 'update_options' : 'get_options' ), '6.3' );
	return current_user_can( 'manage_options' );
}