Removing Settings and Help Sub-Menus

Home Forums Calendar Products Events Calendar PRO Removing Settings and Help Sub-Menus

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #49979
    Darren Rousar
    Participant

    I’d like to restrict some of my users from the ability to see the settings screen (and help) in the dashboard menu.
    Adminimize has the checkboxes for this but I can’t get those two aspects to turn off. I succeed with everything else I try to disallow though and have reinstalled that plugin a number of times (dropping the db fields as well).

    Is there a function I can use to accomplish this instead?

    #49986
    Barry
    Member

    You could add a snippet like this to your theme’s functions.php file (or some other suitable place).

    You’d need to add some additional logic if you have specific criteria in terms of who should and shouldn’t see those items, though.

    #49999
    Darren Rousar
    Participant

    Thanks Barry, I’ll try that in the morning.
    Where did the 5 and then the 50 come from?

    #50022
    Barry
    Member

    They are action/filter priorities, used to determine when the corresponding pieces of code will run.

    #50032
    Darren Rousar
    Participant

    Interesting.
    I’ve a lot to learn.
    Might I have a hint though? Are they somewhat arbitrary in your example?

    #50054
    Darren Rousar
    Participant

    Added this to allow the admin to have access but not the authors:
    if ( !current_user_can( ‘edit_users’ ) ) {
    add_action(‘admin_menu’, ‘remove_tribe_menu_items’, 5);
    }

    function remove_tribe_menu_items() {
    remove_action(‘admin_menu’, array(TribeSettings::$instance, ‘addPage’));
    remove_action(‘admin_menu’, array(TribeEvents::instance(), ‘addHelpAdminMenuItem’), 50);
    }

    #50061
    Barry
    Member

    Nice work.

    Are they somewhat arbitrary in your example?

    Not entirely –TribeEvents::instance()->addHelpAdminMenuItem() is set up by The Events Calendar with a priority of 50 and so that same priority must be specified when removing it.

    The priority of 5 for remove_tribe_menu_items() is I guess a little arbitrary – but I chose it because it is earlier than the default priority (10) and so the other related actions would be in place but would not yet have executed when our two remove_action() calls execute – but in fact a number of completely different hooks and priorities could have been used there.

    In any case, it sounds like you’re all good here (thanks for reporting back with the final solution – which is always helpful for others) and so I’ll go ahead and close this thread.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Removing Settings and Help Sub-Menus’ is closed to new replies.