WC_REST_WCCOM_Site_Installer_Controller::check_permission()
Check permissions.
Method of the class: WC_REST_WCCOM_Site_Installer_Controller{}
Hooks from the method
Return
true|false|WP_Error
.
Usage
$WC_REST_WCCOM_Site_Installer_Controller = new WC_REST_WCCOM_Site_Installer_Controller(); $WC_REST_WCCOM_Site_Installer_Controller->check_permission( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
Since 3.7.0 | Introduced. |
WC_REST_WCCOM_Site_Installer_Controller::check_permission() WC REST WCCOM Site Installer Controller::check permission code WC 7.7.0
woocommerce/includes/wccom-site/rest-api/endpoints/class-wc-rest-wccom-site-installer-controller.php
public function check_permission( $request ) { $current_user = wp_get_current_user(); if ( empty( $current_user ) || ( $current_user instanceof WP_User && ! $current_user->exists() ) ) { /** * This filter allows to provide a custom error message when the user is not authenticated. * * @since 3.7.0 */ $error = apply_filters( WC_WCCOM_Site::AUTH_ERROR_FILTER_NAME, new Installer_Error( Installer_Error_Codes::NOT_AUTHENTICATED ) ); return new WP_Error( $error->get_error_code(), $error->get_error_message(), array( 'status' => $error->get_http_code() ) ); } if ( ! user_can( $current_user, 'install_plugins' ) || ! user_can( $current_user, 'install_themes' ) ) { $error = new Installer_Error( Installer_Error_Codes::NO_PERMISSION ); return new WP_Error( $error->get_error_code(), $error->get_error_message(), array( 'status' => $error->get_http_code() ) ); } return true; }