Skip to content

Instantly share code, notes, and snippets.

@rafsuntaskin
Last active February 11, 2024 11:17
Show Gist options
  • Save rafsuntaskin/529a71d7761312f491757326e85c89d0 to your computer and use it in GitHub Desktop.
Save rafsuntaskin/529a71d7761312f491757326e85c89d0 to your computer and use it in GitHub Desktop.
Add category to submitted events automatically
<?php
add_action( 'tribe_community_event_created', 'rt_ce_auto_add_cat_for_submission' );
function rt_ce_auto_add_cat_for_submission( $event_id ) {
$tribe_ecp = Tribe__Events__Main::instance();
// replace with your required category ID.
$cat_ids = [ 20 ]; // for multiple values add like this [ 20, 21 ]
wp_add_object_terms( $event_id, $cat_ids, $tribe_ecp->get_event_taxonomy() );
}
@andrasguseo
Copy link

@rafsuntaskin what is the purpose of line 6?

@rafsuntaskin
Copy link
Author

Good catch, that one is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment