Forum Replies Created

Viewing 15 posts - 2,251 through 2,265 (of 2,516 total)
  • Author
    Posts
  • Vladimir
    Keymaster

    Hi,

    The best way to replicate all roles from the main site to all subsites of the network is to click “Update Network” button at User Role Editor opened under “Network Admin – Users”.

    When you click “Update Network” you should see popup window like this
    https://storage.googleapis.com/role-editor/downloads/support/update-network-widgets-access.png
    There is an option there to copy widgets access restrictions from main site to all others with roles together. Does it work as expected?

    I confirm that menu access data is not copied currently. Export/Import data include only roles itself without extra data, like menu, widgets, etc. permissions for that role.
    Initially, as different sites may have different plugins and themes set I did not think that such feature will be requested by users. But I see now, that it may be useful for someone. Your report is not the 1st.

    I plan to add these features to one of the future updates: replicating and export/import all User Role Editor saved data, not roles only.

    in reply to: Custom Admin Menus – Serious Bugs #1736
    Vladimir
    Keymaster

    @birgitEFGS: Thanks for the information. I plan to limit a list of “not selected” URL blocked by “admin menu access” add-on with the URLs only which are included to the admin menu. This should resolve issues similar to one with posts edit page blocking. I will include this fix to the next update (1-2 weeks).

    in reply to: Editor role settings not displaying correctly #1731
    Vladimir
    Keymaster

    Hi Robert,

    Thanks a lot for so detailed recommendations/suggestions. I appreciate it. Especially, the news about Justin Tadlock “Members” plugin recent update. It costs to pay the attention for, really.

    Regards,
    Vladimir.

    in reply to: Custom Capabilities from other Plugins #1730
    Vladimir
    Keymaster

    Hi Ben,

    Do you write about bbPress? URE does not support bbPress capabilities currently.

    Send a download link of other plugin. I will check.

    in reply to: Restrict editing pages by user role? #1727
    Vladimir
    Keymaster

    Thanks for the feedback.

    Just in case it will be helpful, as a ‘must use’ plugin it should work without any “include” in functions.php and thus, for any theme, just from wp-content/mu-plugins folder:
    https://codex.wordpress.org/Must_Use_Plugins

    in reply to: Restrict editing pages by user role? #1724
    Vladimir
    Keymaster

    I offer you to remove related code from the functions.php file. Take file from this zip
    https://storage.googleapis.com/role-editor/downloads/block-pages-for-role.zip
    replace ‘editor’ with ‘franchise’, input your own pages ID list and place this .php file to
    wp-content/mu-plugins folder. Test that it works.
    Then apply your own enhancements if needed.

    in reply to: Restrict editing pages by user role? #1723
    Vladimir
    Keymaster

    Code you showed is incomplete and invalid. It lost the begin of restrict_posts_list() function. Please re-check, what you added to the functions.php

    in reply to: Restrict editing pages by user role? #1721
    Vladimir
    Keymaster

    This is the updated version, which takes into account front-end and blocks editing selected pages. You need update it for your role.

    
    add_action('pre_get_posts', 'restrict_posts_list');
    
    function restrict_posts_list($query) {
    
        if ( !is_blog_admin()) { 
            return $query;
        }
        
        if (current_user_can('administrator') || !current_user_can('editor'))  {
            return $query;
        }
        
        $suppressing_filters = $query->get('suppress_filters'); // Filter suppression on?
    
        if ($suppressing_filters) {
            return query;
        }
    
        if ($query->query['post_type']=='page') {            
            $posts_restriction_type = 2; // Prohibit
            $posts_list = array(709, 763);  // comma separated list of pages IDs
            if ($posts_restriction_type==1) {   // Allow
                $query->set('post__in', $posts_list);
            } else {    // Prohibit
                $query->set('post__not_in', $posts_list);
            }
        }
    
        return $query;
    }
    // end of restrict_posts_list()
    
    function current_user_has_role($role_to_check) {
        global $current_user;
        
        $has_role = false;
        foreach($current_user->roles as $role) {
            if ($role===$role_to_check) {
                $has_role = true;
                break;
            }
        }
        
        return $has_role;
    }
    // end of current_user_has_role()
    
    function get_pages_capabilities() {
        $cap_object = new stdClass();
        $cap_object->capability_type = 'page';
        $cap_object->capabilities = array();
        $cap_object->map_meta_cap = true;
        $capabilities = (array) get_post_type_capabilities($cap_object);
        
        return $capabilities;
    }
    
    add_filter('map_meta_cap', 'block_edit_pages', 10, 4);
    
    function block_edit_pages($caps, $cap = '', $user_id = 0, $args = array()) {
    
        if (current_user_has_role('administrator') || !current_user_has_role('editor')) {
            return $caps;
        }
        
        if (substr($cap, 0, 4)=='read') {   // do not block read capabilities
            return $caps;
        }
        
        $posts_restriction_type = 2; // Prohibit
        $posts_list = array(709, 763);   // comma separated list of pages IDs
        
    
        $capabilities = get_pages_capabilities();        
        if (!isset($capabilities[$cap])) {
            return $caps;
        }
    
        if (count($args) > 0) {
            $post_id = $args[0];
        } else {
            $post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT);
        }
        if (empty($post_id)) {
            return $caps;
        }
    
        $post = get_post($post_id);    
        if (empty($post) || $post->post_type!=='page') {
            return $caps;
        }
    
        $do_not_allow = in_array($post_id, $posts_list);    // not edit these pages
        if ($posts_restriction_type == 1) {
            $do_not_allow = !$do_not_allow;   // not edit other pages
        }
        if ($do_not_allow) {
            $caps[] = 'do_not_allow';
        }
    
        return $caps;
    }
    // end of block_edit_pages()
    
    in reply to: Editor role settings not displaying correctly #1718
    Vladimir
    Keymaster

    Hi Robert,

    Thanks for the information.
    Refund was done.

    Regards,
    Vladimir.

    in reply to: Restrict editing pages by user role? #1716
    Vladimir
    Keymaster

    Add to the begin of function:

    
    function restrict_post_list($query) {
    
    if (is_super_admin() || current_user_can('administrator')) {
        return $query;
    }
    ...
    

    or change the initial if condition to:

    
    if (is_blog_admin() && !(is_super_admin() || current_user_can('administrator')) && current_user_can('franchise')) {
    
    in reply to: Restrict editing pages by user role? #1711
    Vladimir
    Keymaster

    AntKat,
    This is a version of code modified to work with a list of pages slugs:

    
    add_action('pre_get_posts', 'restrict_posts_list');
    
    function restrict_posts_list($query) {
    
        if ( !(is_blog_admin() && current_user_can('editor')) ) {
            return $query;
        }
        $suppressing_filters = $query->get('suppress_filters'); // Filter suppression on?
    
        if ($suppressing_filters) {
            return query;
        }
    
        if ($query->query['post_type']=='page') {            
            $posts_restriction_type = 2; // Prohibit
            $posts_slugs = array(
                'jobs',
                'post-to-our-blog',
                'sample-page'
            );
            $posts_list = array();  // comma separated list of pages IDs
            foreach($posts_slugs as $post_slug) {
                $page = get_page_by_path($post_slug);
                if ($page) {
                    $posts_list[] = $page->ID;   
                }
            }
            if (empty($posts_list)) {
                return $query;
            }
            if ($posts_restriction_type==1) {   // Allow
                $query->set('post__in', $posts_list);
            } else {    // Prohibit
                $query->set('post__not_in', $posts_list);
            }
        }
    
        return $query;
    }
    // restrict_posts_list()
    
    in reply to: FSQM #1708
    Vladimir
    Keymaster

    List of custom user capabilities used at the FSQM menu:
    Menu Item Capability
    FSQM Pro view_feedback
    Dashboard view_feedback
    View all Forms manage_feedback
    New Form manage_feedback
    Import/Export Forms manage_feedback
    Form Category manage_feedback
    Report & Analysis view_feedback
    View a Submission view_feedback
    View all Submissions manage_feedback
    Settings manage_feedback

    in reply to: FSQM #1707
    Vladimir
    Keymaster

    Hi Tash,

    If it’s a paid product please send its copy to [email protected]
    I will use it at my localhost for the investigation purpose only.
    If it’s a plugin from WordPress repository send here its download link.

    in reply to: Do I need to install both Free and Pro versions? #1700
    Vladimir
    Keymaster

    Hi Helen,

    Pro version includes its own copy of a free version (or the core of a User Role Editor). So you can remove free version. The only thing that you should remember is that both versions (free and Pro) use the same place to store their settings data. So if you delete free version via WordPress Plugins Delete link, plugin will delete automatically its settings data. You will have to configure User Role Editor Pro Settings again after that.
    Right decision in your case is to delete free version folder (user-role-editor) via FTP not via WordPress.

    in reply to: Restrict editing pages by user role? #1698
    Vladimir
    Keymaster

    Hi,

    Thanks for letting me know. I will add it.

Viewing 15 posts - 2,251 through 2,265 (of 2,516 total)