Automattic\WooCommerce\Admin\API
Options::user_has_permission
Check if the user has permission given an option name.
Method of the class: Options{}
No Hooks.
Returns
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() Options::user has permission code WC 10.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 ];
}
wc_deprecated_function( 'Automattic\WooCommerce\Admin\API\Options::' . ( $is_update ? 'update_options' : 'get_options' ), '6.3' );
// Disallow option updates in non-production environments unless the option is whitelisted, prompting developers to create specific endpoints in case they miss the deprecation notice.
if ( 'production' !== wp_get_environment_type() ) {
return false;
}
return current_user_can( 'manage_options' );
}