By default, managing the options of most features from Blocksy are locked to users who have administrative rights. This is to protect against various abuse cases that could arise. By default, most of the features default to requiring the manage_options
capability from the user that tries to make changes.
With the blocksy:capabilities:wp_capability
we are introducing a way to make changes in that process. The filter allows changing the capability for multiple places (called scopes) and it allows you to target individual instances within the scope (that said, you can target one specific custom post type if you want or just all at once).
Places where the filter is supported right now
The following table will show all of the supported scopes and their respective default values.
Scope | Default Value |
---|---|
Content Blocks Scope: custom_post_type Scope details: ['post_type' => 'ct_content_block'] | manage_options |
Thank You Pages Scope: custom_post_type Scope details: ['post_type' => 'ct_thank_you_page'] | manage_options |
Product Tabs Scope: custom_post_type Scope details: ['post_type' => 'ct_product_tab'] | manage_options |
Size Guides Scope: custom_post_type Scope details: ['post_type' => 'ct_size_guide'] | manage_options |
Size Guides Scope: conditions Scope details: [] | manage_options |
Example usage. By knowing the $scope
and $scope_details
you can change the capability in a very targeted fashion.
add_filter(
'blocksy:capabilities:wp_capability',
function ($capability, $scope, $scope_details) {
if ($scope === 'custom_post_type') {
if (
$scope_details['post_type'] === 'ct_content_block'
||
$scope_details['post_type'] === 'ct_product_tab'
) {
return 'shop_manager';
}
}
return $capability;
},
10,
3
);
This specific example permits editing of Content Blocks and Custom Tabs post types by a user that has the shop_manager
capability.