Site icon Hip-Hop Website Design and Development

Plugin to restrict access to pages in wp-admin

I’ve searched all day for this and couldn’t find a plugin that allow me to restrict the access to specific pages in the wp-admin backed by user role.

Example: I have several users on my website and I want them to only see the pages that they are allowed to edit. I’ve done this manually by code and it’s working (see code below), but I wanted a plugin that allowed me to the same thing.

Why? Because I have a support team that manages the site and they can’t code. Every time I need to add a page or allow someone else on some page I need to manually go there and edit that file.

The closest I came to a solution was the Pages by User Role plugin, on CodeCanyon, but it doesn’t work on the backend. Something similar that works on the backend would be great.

if(current_user_can('custom-editor')){
    function allowed_pages_custom_e($query) {
        global $pagenow,$post_type;
        if (is_admin() && $pagenow=='edit.php' && $post_type =='page') {
            $query->query_vars['post__in'] = array('11678');
        }
    }
    add_filter( 'parse_query', 'allowed_pages_custom_e' );
}