Protecting Custom Post Types by Default
This feature allows you to protect all existing custom post type entries on your site as well as protect all new custom post types by default. You can restrict custom post types for guests, members and specific user roles.
Content of restricted custom post types will be hidden from Category, Tag, Taxonomy, Archive, Author pages as well as RSS feeds. Simple restriction message will be displayed for restricted custom post types on these pages.
Let’s see how we can enable global restrictions for custom post types.
Using Restriction Settings
You can go to Private Content Settings -> Global Restrictions to see the available custom post types. All custom post types will be listed along with posts and pages. You can select a custom post type and add the global protection settings as shown in the following screenshot. In this scenario, we are applying restrictions to WooCommerce Products.
First, you have to select the Enable Global Product Restrictions setting for products to apply the protection. This setting is disabled by default. Then you need to select an option for the Visibility setting. Let’s identify the available options.
- Guests – Allows you to make all existing and new products(Custom Post Types) visible only to guest users who doesn’t have a user account.
- Members – Allows you to make all existing and new products(Custom Post Types)visible only to members who have a user account and logged into the site.
- Selected User Roles – Allows you to make all existing and new products(Custom Post Types)visible only to the selected user roles
If you choose Selected User Roles option, you will get another setting called Allowed User Roles as shown in the following screenshot. You can select the user roles allowed to view all existing and new products(Custom Post Types) by default.
If someone is not allowed to access the product(Custom Post Types), they will be redirected to the URL specified for global Post/Page Restriction Redirect URL setting as shown in the following screenshot.
Important – You can override global product(Custom Post Types) protection setting by adding new settings on individual products(Custom Post Types).