27
Mar, 2015
Mar, 2015
How can I control access to the s2Member Post/Page Restrictions Meta Box?
s2Member allows any WordPress user with a Role that allows permission to edit Posts/Pages to also have access to the s2Member Post/Page Restrictions Meta Box on the Post/Page editing page:
If you want to customize this behavior and limit access to the s2Member Post/Page Restriction Meta Box, there is an s2Member filter that will allow you to limit access given your specific rules. You could create an MU-Plugin with the following code:
<?php
add_filter('ws_plugin__s2member_add_meta_boxes_excluded_types', function($excluded_post_types)
{
if(!current_user_can('SOMETHING')) # If they are not allowed, exclude all post types.
$excluded_post_types = array_keys(get_post_types());
return $excluded_post_types;
});
In this example, you could change SOMETHING
to any WordPress Capability (see WordPress Codex). You could also customize this code to use a different conditional that checks for something else that lets you control access to the s2Member Post/Page Restrictions Meta Box.