Home › Forums › Calendar Products › Community Events › Warning when Organizer Email Required snippet is used
- This topic has 5 replies, 2 voices, and was last updated 10 years, 5 months ago by
Brian.
-
AuthorPosts
-
November 23, 2015 at 2:14 pm #1029834
Graphic
ParticipantHello,
I would like to make the organizer email required on our Community Events submission form.
I have pasted Brian’s snippet into our child theme functions.php file, as per this thread: https://theeventscalendar.com/support/forums/topic/make-organizer-email-required/#dl_post-1007511Here’s what I’m using:
add_filter( ‘tribe_events_community_required_fields’, ‘tribe_community_required_fields_org_email’, 10, 1 );
function tribe_community_required_fields_org_email( $fields ) {$required_email = $_POST[‘organizer’][‘Email’];
foreach( $required_email as $email) {
if ( empty( $email ) )
$fields[] = ‘Organizer Email’;
}return $fields;
}There is now a message on the page that says Warning: Invalid argument supplied for foreach()
We are using the Enfold theme. I’ve posted the page link in private data.When I activate Twenty Fifteen or Twenty Fourteen themes, the warning message doesn’t appear, and they also don’t prompt for an organizer email if the field is left empty when submitting an event.
The Enfold Theme however shows the warning. When an event is submitted without an organizer email, it shows an error message for the missing email field, plus adds an additional organizer section below the original one, showing two organizer sections instead of one.
Maybe I’ve included the code incorrectly. Please let me know. Thanks
November 23, 2015 at 6:51 pm #1029898Brian
MemberHi,
Thanks for using our plugins. I can help out here.
What file did you put the snippet into?
When do you get this message?
Warning: Invalid argument supplied for foreach()
Does it always show? or just if you click submit.
Thanks
November 23, 2015 at 10:01 pm #1029910Graphic
ParticipantThis reply is private.
November 24, 2015 at 12:35 pm #1030352Brian
MemberHi,
This is not an official feature so I am limited in supporting it and it may not work in all cases.
I found this coding gets rid of the warnings and notices:
add_filter( ‘tribe_events_community_required_fields’, ‘tribe_ommunity_required_fields_org_email’, 10, 1 );
function tribe_ommunity_required_fields_org_email( $fields ) {
if ( isset ( $_POST ) && isset( $_POST[‘organizer’] ) ) {$required__field_id = $_POST[‘organizer’][‘OrganizerID’];
if ( is_array( $required__field_id ) ) {
$i = 0;
foreach ( $required__field_id as $organizer_id ) {
if ( $organizer_id > 0 ) {
$i++;
} elseif ( empty( $_POST[‘organizer’][‘Email’][$i] ) ) {
$fields[] = ‘Organizer Email’;
$i++;
}
}}
} elseif ( isset ( $_POST ) && ! isset( $_POST[‘organizer’] ) ) {
$fields[] = ‘Organizer’;
}return $fields;
}It should also now account for the existing Organizers and work for them.
Let me know how that works out.
Thanks
November 24, 2015 at 3:25 pm #1030420Graphic
ParticipantThat seems to have worked. Thanks so much!
November 24, 2015 at 5:36 pm #1030446Brian
MemberGreat, glad it helps, I am going to go ahead and close this ticket, but if you need help on this or something else please post a new ticket.
Thanks!
-
AuthorPosts
- The topic ‘Warning when Organizer Email Required snippet is used’ is closed to new replies.
