Home › Forums › Calendar Products › Community Events › Required fields for event submission form: Code doesn't work anymore
- This topic has 10 replies, 2 voices, and was last updated 6 years, 8 months ago by Oliver.
-
AuthorPosts
-
August 4, 2017 at 10:33 am #1330863OliverParticipant
Hi,
after one of the latest releases (probably the one which completely changed the event submission form) the code that is offered here to
a) add required fields
https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form/and
doesn’t work anymore.
Any idea why? Have the filters used above
– add_filter( ‘tribe_events_community_required_fields’, ‘my_community_required_fields’, 10, 1 );
– add_filter( ‘tribe_community_events_form_errors’, ‘ce_custom_error_msg’ );
maybe removed?Best regards,
Oliver- This topic was modified 6 years, 8 months ago by Oliver.
August 7, 2017 at 10:14 pm #1331928VictorKeymasterHi Oliver!
Thanks for getting in touch with us!
I’m sorry to hear those code snippets are not working for you.
I know there were some issues regarding those required fields in the past, but they were solved. Could you please share with me the code snippets you are using so I can make some tests on my own local installation and see if it works?
Thanks,
VictorAugust 8, 2017 at 3:10 am #1331995OliverParticipantHi Victor,
here is the code I’m using. I’m using it untouched for a long time – maybe >1 year.
Would be great I you have an idea 🙂//----------------------------------------------------------------------------------- // Make additional fields required in Community events submission page // https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form/ //----------------------------------------------------------------------------------- function my_community_required_fields( $fields ) { if ( ! empty($_FILES['event_image']['name']) ) { $fields = array( 'post_title', 'post_content', 'EventStartDate', 'venue', '_ecp_custom_1', '_ecp_custom_3' ); } else if ( ! empty( $_POST['_ecp_custom_1']) ) { $fields = array( 'post_title', 'post_content', 'EventStartDate', 'venue', 'event_image', '_ecp_custom_3' ); } else { $fields = array( 'post_title', 'post_content', 'EventStartDate', 'venue', '_ecp_custom_3' ); } return $fields; } add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 ); //----------------------------------------------------------------------------------- // Check, it not allowed characters have been entered in the cost. Allowed are: A-z, 0-9 // https://theeventscalendar.com/knowledgebase/required-fields-for-events-submission-form/?source=tri.be&q=/change-required-fields-on-community-event-submission-page/#errors //----------------------------------------------------------------------------------- function ce_custom_error_msg( $errors ) { $cost = trim( $_POST['EventCost'] ); if ( empty( $cost ) ) { return false; } if ( preg_match( "/^[a-zA-Z0-9,. \s]+$/", $cost ) ) { return $errors; } $existing_errors = ''; $type = 'error'; if ( is_array( $errors ) ) { $existing_errors = $errors[0]['message']; $type = $errors[0]['type']; } $errors[0] = array( 'type' => $type, 'message' => 'Unerlaubte Zeichen im Eintrittsfeld! Bitte geben Sie den Eintrittspreis z.B. wie folgt ein:<li>26</li><li>26-30</li><li>Spende</li>Ergänzen Sie weitere Infos bitte bei der Beschreibung der Veranstaltung!' . $existing_errors ); return $errors; } add_filter( 'tribe_community_events_form_errors', 'ce_custom_error_msg' );
Best regards,
OliverAugust 8, 2017 at 9:43 pm #1332621VictorKeymasterHi Oliver!
Thanks for coming back with the code.
Despite throwing a PHP warning, I could make the required fields work on my local installation.
Just to confirm, are you not able to get any of the required fields to work, or just some of them?
In addition, are you making any template customization for the community add form? If so, let us know about it.
Thanks,
VictorAugust 9, 2017 at 10:57 am #1333002OliverParticipantThis reply is private.
August 9, 2017 at 9:48 pm #1333266VictorKeymasterThis reply is private.
August 10, 2017 at 1:55 am #1333312OliverParticipantWow, now it works! 🙂
But where is the difference in the code? I can’t see any!
Best regards,
OliverAugust 10, 2017 at 7:28 am #1333436VictorKeymasterHey Oliver!
Glad it worked out for you! 🙂
The difference was inside the ce_custom_error_msg() function. You were returning false when cost was empty, thus not returning all other error messages.
Is there anything else I can help you with? Let me know.
Best,
VictorAugust 10, 2017 at 10:26 am #1333592OliverParticipantOh, that was too simple 😉
Thanks for finding it!!! Best man!!
Best regards,
OliverAugust 10, 2017 at 12:00 pm #1333638VictorKeymasterI’m happy to help Oliver 🙂
I’ll close this now, but feel free to open a new topic if anything comes up.
Cheers!
Victor -
AuthorPosts
- The topic ‘Required fields for event submission form: Code doesn't work anymore’ is closed to new replies.