Home › Forums › Calendar Products › Events Calendar PRO › Disable Editing of Event Categories
- This topic has 3 replies, 3 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
March 20, 2013 at 5:08 pm #43454Denise CrosbieParticipant
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.
March 20, 2013 at 6:49 pm #43503Denise CrosbieParticipantK, 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’);March 21, 2013 at 12:38 pm #43700JonahParticipantHi manitobathunder,
Nice solution! Looks like you’re all set here then. Please let us know if you need help with anything else.
Thanks,
JonahJuly 7, 2015 at 6:26 am #978844Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Disable Editing of Event Categories’ is closed to new replies.