Forum Replies Created
-
AuthorPosts
-
Mark
ParticipantThanks Brian this worked like a charm. For those interested, here is the complete functions.php (removed the initial wp_enqueue_scripts action because it’s not relevant here).
<?php add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 ); function my_community_required_fields( $fields ) { $fields = array( 'post_title', 'post_content', 'organizer', ); return $fields; } add_filter( 'tribe_events_community_required_fields', 'tribe_ommunity_required_fields_org_email', 10, 1 ); function tribe_ommunity_required_fields_org_email( $fields ) { $required_email = $_POST['organizer']['Email']; foreach( $required_email as $email) { if ( empty( $email ) ) $fields[] = 'Organizer Email'; } return $fields; } add_filter( 'tribe_events_community_required_fields', 'tribe_ommunity_required_fields_venue_city', 10, 1 ); function tribe_ommunity_required_fields_venue_city( $fields ) { if ( empty( $_POST['venue']['Venue'] ) ) $fields[] = 'Venue Name is Required'; if ( empty( $_POST['venue']['City'] ) ) $fields[] = 'Venue City is Required'; return $fields; } ?>And then to add “required” to the Venue Name & City on the front-end I copied /wp-content/plugins/the-events-calendar-community-events/src/views/community/modules/venue.php to my theme at my-theme/tribe-events/community/modules/venue.php and edited the code to include the “required” message.
Thanks again Brian.
Mark
ParticipantHey Brian,
Thanks for the reply. That works for me. It clears the form fields already entered in the Organizer section if you miss either Name/Email so the user has to re-enter them but it’s a pretty minor issue.
I also would like the Venue City field to be required. Same problem, when I set ‘venue’ to be required in functions.php it only requires the Venue Name.
I tried copying your function and renaming to venue city (see below, I’ve included my entire functions.php) but no luck. Any thoughts on that one?
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 ); function my_community_required_fields( $fields ) { $fields = array( 'post_title', 'post_content', 'venue', 'organizer', ); return $fields; } add_filter( 'tribe_events_community_required_fields', 'tribe_ommunity_required_fields_org_email', 10, 1 ); function tribe_ommunity_required_fields_org_email( $fields ) { $required_email = $_POST['organizer']['Email']; foreach( $required_email as $email) { if ( empty( $email ) ) $fields[] = 'Organizer Email'; } return $fields; } add_filter( 'tribe_events_community_required_fields', 'tribe_ommunity_required_fields_venue_city', 10, 1 ); function tribe_ommunity_required_fields_venue_city( $fields ) { $required_city = $_POST['venue']['City']; foreach( $required_city as $city) { if ( empty( $city ) ) $fields[] = 'Venue City'; } return $fields; } ?> -
AuthorPosts
