Disabling Editing of Event Categories

Home Forums Calendar Products Events Calendar PRO Disabling Editing of Event Categories

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1632769
    phylaxis
    Participant

    I wanted to be able to do this and I mean across this old post: https://theeventscalendar.com/support/forums/topic/disable-editing-of-event-categories/

    While the answer is a good one a concern I had was by overriding the entire Tribe Events register_taxonomy call it could cause issues with future updates. Below is my modified solution which reads the original parameters and then just overrides the capabilities section and then re-registers the taxonomy. Thought it might be helpful to others in the future.

    function bdc_tribe_events_cat() {
    
        //only needed in admin
        if( !is_admin() )
        {
            return;
        }
    
        // get the arguments of the already-registered taxonomy
        $events_category_args = get_taxonomy( 'tribe_events_cat' ); // returns an object
    
        $new_permissions = array(
            'manage_terms'. => 'update_themes',
            'edit_terms'.        => 'update_themes',
            'delete_terms'.    => 'update_themes',
            'assign_terms'.    => 'update_themes'
        );
    
        $events_category_args->cap = $new_permissions;
    
        register_taxonomy( 'tribe_events_cat', 'tribe_events', (array) $events_category_args);
    }
    
    //only admins can edit event categories
    add_action( 'init', 'bdc_tribe_events_cat', 11 );
    #1634935
    Barry
    Member

    Hi there @phylaxis,

    We appreciate you sharing this – thank you!

    #1634937
    Barry
    Member

    This reply is private.

    #1635415
    phylaxis
    Participant

    This reply is private.

    #1635651
    Barry
    Member

    This reply is private.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Disabling Editing of Event Categories’ is closed to new replies.