#4281
Vladimir
Keymaster

This code does not depend from a page ID. It blocks edit access for pages with ‘shop’ and ‘busket’ slugs for any user with ‘edit_others_pages’ capability for any subsite.


add_filter('ure_edit_posts_access_id_list', 'ure_edit_posts_access_set_id_list');

function ure_edit_posts_access_set_id_list($list) {
    $current_user = wp_get_current_user();
    $lib = URE_Lib_Pro::get_instance(); 
    if (!current_user_can('edit_others_pages')) {
        return $list;
    }
    
    $slugs = array('shop', 'busket');
    $id_list = array();
    foreach($slugs as $slug) {
        $page = get_page_by_path($slug);
        if (!empty($page)) {
            $id_list[] = $page->ID;
        }
    }
    $id_list_str = implode(',', $id_list);
    $list .= $id_list_str;

    return $list;
}

add_filter('ure_edit_posts_access_restriction_type', 'ure_edit_posts_access_set_restriction_type');

function ure_edit_posts_access_set_restriction_type($restriction_type) {
    $current_user = wp_get_current_user();
    $lib = URE_Lib_Pro::get_instance(); 
    if (current_user_can('edit_others_pages')) {
        $restriction_type = 2; // Block
    }
    
    return $restriction_type;
}

If you will wish to add some edit restriction for user with ‘edit_others_pages’ manually, you should take into account that this restricton should be the same type “Block” in order to not break this code and vice versa.