Hi,
Thanks for sharing information about User Role Editor and its Pro version.
In relation to your plugin user support request:
1st, you define a ‘lightbox-slider’ custom post type with a capability type ‘page’. It automatically forces to grant to user all ‘%_pages’ capabilities in order such user has a full access to your galleries.
User Role Editor shows (0/0) for such custom post types as ‘edit_pages’, etc. capabilities are shown already for the built-in ‘Pages’ post type. There is no incompatibility issue here.
User Role Editor Pro has an option which allows to force custom post types to use own capabilities set instead of ‘post’ or ‘page’ built-in types related one.
But this will resolve a problem just partially as there is the 2nd difficulty with providing to a user without administrator privileges a full access to your plugin.
2nd, you add “Lightbox Slider” menu items with ‘administrator’ role instead of user capability. So only user with ‘administrator’ role can access “Lightbox Slider->Settings” and other menu items.
I offer to replace ‘administrator’ in your menu definition with more fluent ‘manage_options’ or with your own custom capability, like ‘manage_lightbox_slider’. User with ‘manage_lightbox_slider’ will not get access to any other site and some plugins settings like with ‘manage_options’ capability. Thus 2nd variant is more secure.
In order do not force “Lightbox Slider” users to buy User Role Editor Pro, and make your plugin more universal, you can define ‘lightbox-slider’ post type with own capabilities set from the scratch. Modify your code this way, file lightbox-slider.php, from line #113:
$args = array(
'label' => __( 'Lightbox Slider', WEBLIZAR_LBS_TEXT_DOMAIN ),
'description' => __( 'Lightbox Slider', WEBLIZAR_LBS_TEXT_DOMAIN ),
'labels' => $labels,
'supports' => array( 'title', '', '', '', '', '', '', '', '', '', '', ),
//'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'show_in_admin_bar' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-gallery',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => false,
'capability_type' => 'lightbox_slider',
'map_meta_cap' => true
);
$lb_post_type = register_post_type( 'lightbox-slider', $args );
// add custom capabilities for lightbox-slider post type to the 'administrator' role
global $wp_roles;
$role = $wp_roles->role_objects['administrator'];
foreach ($lb_post_type->cap as $cap) {
if (!isset($role->capabilities[$cap])) {
$role->add_cap($cap);
}
}
Look at 2 last items of $args array. I changed capability_type from ‘page’ to ‘lightbox_slider’ and added map_meta_cap argument with true value.
Then I add new capabilities from your post type to the ‘administrator’ role in order provide access to your post type to at least administrators as the 1st step on plugin activation.