Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    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.

    Plugin Author Vladimir Garagulya

    (@shinephp)

    If you will define “Settings” and other menu items with ‘manage_lightbox_slider’ capability then you need to add this capability to ‘administrator’ role. Just add to the end of code about this line:

    
    $role->add_cap('manage_lightbox_slider');
    

    I got all code, very well explained.

    Do I modify only for a specific user?

    Or

    Do make this changes permanently for all user?

    Thanks for so fast reply. 🙂

    Plugin Author Vladimir Garagulya

    (@shinephp)

    You are welcome!

    It will expand an area how users can use your plugin, if you include this changes to your next version. ‘administrator’ will still have full access to your plugin by default, but it will be possible to delegate a work with plugin to the users with lower privileges.

    A specific user will not have to update your plugin code manually after every update of a main version.

    Final decision is for you though.

    Okay, that’s great.

    Thanks so much for all help. User Role Editor such a great plugin.

    I made a recommendation and review for you – https://ww.wp.xz.cn/support/topic/great-recommended-plugin-to-controll-users-usablilty/

    Thanks
    Weblizar

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Make Compatible With Our Plugins’ is closed to new replies.