WordPress: Access Denied

CoCart General Settings

In the settings page under GENERAL, a checkbox option to disable access to WordPress is available. Simply enabling this will prevent anyone who is not administrator trying to access your WordPress site.

What the user will get is a message in JSONYou don’t have permission to access the site.” with a 403 status.

By default, both the cart and checkout pages are still accessible to support the feature “Load cart from session“.

Can I still allow specific pages access?

Yes, additional pages can be made accessible using the filter cocart_accessible_page_ids. Simply push the page ID’s you want and those pages will not be blocked.

Tip: Add the filter using a code snippet plugin for quick application.

add_filter( 'cocart_accessible_page_ids', function( $page_ids ) {
  array_push( $page_ids, array( '224', '548' );
  return $page_ids;

What about redirecting users to my headless site?

Any page that is blocked can be redirected to your headless site domain you have set in the Front-end URL if WordPress has been denied access.

Was this helpful to you?