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' );
}

Topic user-access user-roles plugins Wordpress

Category Web


if( is_admin() ) {
    add_filter( 'init', 'custom_restrict_pages_from_admin' );
}

function custom_restrict_pages_from_admin() {
    global $pagenow;

    $arr = array(
        'update-core.php',
        'edit.php'
    );

    if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) {
        //echo some custom messages or call the functions 
    } else {
        echo 'This page has restricted access to specific roles';
        wp_die();
    }
}

function custom_check_user_roles() {
    //restrict pages by user role 

    if( current_user_can( 'administrator' ) || current_user_can( 'editor' ) ) 
         return true;
    else { 
        echo 'Not allowed!'; 
        wp_die();
    }
}

Use Advanced Access Manager ( https://wordpress.org/plugins/advanced-access-manager/ ) Plugin to restrict users in backend according to their roles....

I thing this will be a better solution for your issue.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.