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
}