Custom Fields
Re-Envisioned
Support General Hiding Meta Box Plugin from WordPress Dashboard Menu for Non-Admins

  • Creator
    Topic
  • #27373
    Resolved omarthegeek
    Participant

    The Meta Box plugin is currently visible as an item on the WordPress Dashboard Menu to Administrators as well as non Administrators users ex: Editor User.

    While those non Administrators get a message saying "Sorry, you are not allowed to access this page.", I would very much prefer the plugin was fully hidden from them instead of showing them something they shouldn't have access to.

    I know there are plugins out there for customizing the menu and such, but I would rather prefer a simple script to add to functions.php to hide it from all users except Administrators.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #27382
    Long Nguyen
    Moderator

    Hi Omar,

    Please try to use this code to remove the Meta Box menu from the dashboard if the user is not an administrator.

    add_action( 'admin_init', 'remove_menu_metabox' );
    
    function remove_menu_metabox() {
        if ( !current_user_can( 'administrator' ) ) { //change role or capability here
            remove_menu_page( 'meta-box' );
        }
    }
    #27398
    omarthegeek
    Participant

    Worked beautifully, Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.