Remove or Hide Admin Menu Links for Certain or Specific Users or Roles


/ Published in: PHP
Save to your folder(s)

In this example I used the "Members" plugin to add a capability called "hide_jobs" and that was the trigger to hide certain admin menus and also hide the "Right Now" dashboard widget.


Copy this code and paste it in your HTML
  1. if (current_user_can('hide_jobs')) {
  2. add_action( 'admin_menu', 'my_remove_menu_jobs' );
  3. function my_remove_menu_jobs() {
  4. remove_menu_page('edit.php?post_type=job');
  5. remove_menu_page('edit.php?post_type=solution');
  6. remove_meta_box('dashboard_right_now', 'dashboard', 'normal'); // right now
  7. }
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.