0

I have removed some menu links for a basic contributor role, just that when the user access the edit post section they re-appear(wp-admin/post.php?post=24731&action=edit). What am I missing? This is my code:

if (current_user_can('basic-contributor')) {
    function remove_menus_contrib(){

      remove_menu_page( 'edit-comments.php' );    
      remove_menu_page( 'tools.php' );                   
      remove_menu_page( 'edit.php?post_type=directory' );                 
      remove_menu_page( 'edit.php?post_type=city' );    

    }
    add_action( 'admin_menu', 'remove_menus_contrib' );
    function profile_redirect() {
        $not_allowed = array(
        'edit.php?post_type=city', 
        'edit.php?post_type=directory',
        'tools.php',
        'edit-comments.php'
        );
        $result = str_replace('/wp-admin/', '', $_SERVER['REQUEST_URI']);
        if (in_array($result, $not_allowed) !== false) {
            wp_redirect(get_option('siteurl') . '/wp-admin/index.php');
            exit;
        }
    }
    add_action('admin_menu', 'profile_redirect');   // disabling access
}
2
  • Try User Role Editor plugin. Oct 25, 2014 at 21:11
  • @Ashok Tried that and created a Basic Contributor that can edit_posts (his own) and read.
    – Adrian
    Oct 26, 2014 at 7:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.