Disable Editing of Event Categories

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #43454
    Denise Crosbie
    Participant

    I see this post where this user wants to do the exact same thing I do – limit the editing of event categories based on user role:
    https://theeventscalendar.com/support/forums/topic/user-capabilities-for-categories/

    You say we can “call register_taxonomy() a second time and overwrite the capabilities”. Can you give me some code to do this? I am quite familiar with editing wordpress code, however I have never taken the time to learn about taxonomies and capabilities.

    A code sample for calling register_taxonomy() to make edit categories only available to certain users (in my case authors) would be super useful.

    #43503
    Denise Crosbie
    Participant

    K, I m obviously impatient so I dug around in the code and read up on taxonomies and came up with the following tidbit in functions.php which seems to be working to only allow admins access to edit event categories. Hopefully it doesn’t break something, but I tested and it seems to work great.

    function my_custom_init() {
    //make it so that non-admin users can not edit event categories
    register_taxonomy( ‘tribe_events_cat’, ‘tribe_events’, array(
    ‘hierarchical’ => true,
    ‘update_count_callback’ => ”,
    ‘rewrite’ => array( ‘slug’=> ‘events/’ . sanitize_title( __( ‘category’, ‘tribe-events-calendar’ ) ), ‘with_front’ => false ),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘labels’ => array(
    ‘name’ => __( ‘Event Categories’, ‘tribe-events-calendar’ ),
    ‘singular_name’ => __( ‘Event Category’, ‘tribe-events-calendar’ ),
    ‘search_items’ => __( ‘Search Event Categories’, ‘tribe-events-calendar’ ),
    ‘all_items’ => __( ‘All Event Categories’, ‘tribe-events-calendar’ ),
    ‘parent_item’ => __( ‘Parent Event Category’, ‘tribe-events-calendar’ ),
    ‘parent_item_colon’ => __( ‘Parent Event Category:’, ‘tribe-events-calendar’ ),
    ‘edit_item’ => __( ‘Edit Event Category’, ‘tribe-events-calendar’ ),
    ‘update_item’ => __( ‘Update Event Category’, ‘tribe-events-calendar’ ),
    ‘add_new_item’ => __( ‘Add New Event Category’, ‘tribe-events-calendar’ ),
    ‘new_item_name’ => __( ‘New Event Category Name’, ‘tribe-events-calendar’ )
    ),
    ‘capabilities’ => array(
    ‘manage_terms’ => ‘update_themes’,
    ‘edit_terms’ => ‘update_themes’,
    ‘delete_terms’ => ‘update_themes’,
    ‘assign_terms’ => ‘update_themes’
    )
    ));
    }
    add_action(‘init’, ‘my_custom_init’);

    #43700
    Jonah
    Participant

    Hi manitobathunder,

    Nice solution! Looks like you’re all set here then. Please let us know if you need help with anything else.

    Thanks,
    Jonah

    #978844
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

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