Home › Forums › Calendar Products › Community Events › Make organizer email required
- This topic has 5 replies, 2 voices, and was last updated 10 years, 7 months ago by
Brian.
-
AuthorPosts
-
September 18, 2015 at 8:27 am #1006461
Mark
ParticipantHi All,
I would like to make the Organizer Email field required.
I’ve read this article: https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form.
When it says it makes the whole Organizer section required it really means that it only makes Organizer Name required. The instructions for making Organizer Email required are incomplete (as far as I understand).
I’ve seen a few other forum posts asking for help but so far the response I see is that no further help can be offered from Modern Tribe.
Is that the case? If so, have any members of the community had any luck making Organizer Email required?
Thanks.
September 21, 2015 at 7:15 am #1007006Brian
MemberHi,
Thanks for using our plugins. I can help out here.
It looks like the Multi Organizer Feature prevents the traditional Required Fields from working.
I got this snippet to work for me:
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 that to your theme’s functions.php and let me know how that works out for you.
Thanks
September 21, 2015 at 11:14 am #1007156Mark
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; } ?>September 21, 2015 at 3:25 pm #1007270Brian
MemberHi,
That coding for the organizer will only work for the organizer as it can have multiple values.
If you want only the venue name and city use this:
if ( empty( $_POST['venue']['Venue'] ) )
$fields[] = 'Venue Name is Requried';if ( empty( $_POST['venue']['City'] ) )
$fields[] = 'Venue City is Requried';
And remove venue from here:
$fields = array(
'post_title',
'post_content',
'venue',
'organizer',
);Cheers
September 22, 2015 at 8:03 am #1007511Mark
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.
September 22, 2015 at 1:41 pm #1007630Brian
MemberGreat glad it helps. I am going to take all these snippets and add them to our guide to help out in the future.
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks
-
AuthorPosts
- The topic ‘Make organizer email required’ is closed to new replies.
