Home › Forums › Calendar Products › Community Events › Customizing the Required Fields Error Message post-3.7 release
- This topic has 12 replies, 4 voices, and was last updated 11 years, 6 months ago by
Leah.
-
AuthorPosts
-
August 1, 2014 at 6:22 pm #561571
irishrunner16
ParticipantHi guys,
I’m updating my Community template overrides with the changes for 3.7 and am having trouble customizing the error message displayed for the required fields.Previously, the snippet described here worked, but it isn’t producing a custom message after updating to 3.7.
Any advice on how can we customize the default error messages that are displayed for the individual fields? For example, I’d like to change “Tax Input is required” to “Event Category is required”.
Thanks,
SeanAugust 3, 2014 at 9:08 pm #574155Tony Ash
ParticipantSame issue here…
August 4, 2014 at 9:03 am #578684Casey D
MemberHello irishrunner16 and ‘Tony’,
Thanks for letting us know about this, looks like we removed that filter.
I’m not sure if it was intentional or not, but to me it seems like we made a mistake. Functionality that was in 3.6 is broken in 3.7.
I’ve created a ticket and escalated the issue. By the end of the day I will have a work around or at least an update.
Let me know if I can help with anything else! Sorry for the frustration!
– Casey Driscoll
August 4, 2014 at 6:46 pm #582466Casey D
MemberHey there, here is some code for a work around. I think it might be the solution going forward as well. We’ll update that tutorial in the next few days once we finish the edges.
add_filter( ‘tribe_community_events_form_errors’, ‘ce_custom_error_msg’ );
function ce_custom_error_msg( $errors ) {
$message = ‘<h5>There was a problem saving your event. The following fields are required:</h5>’;
$errors[0][‘message’] = $message . $errors[0][‘message’];return $errors;
}With that filter you can also screen any text you want in the $error[0][‘message’] string, to replace your “Tax Input is required” to “Event Category is required”.
Does this make sense? Let me know if this doesn’t work for you.
Cheers!
– Casey Driscoll
August 5, 2014 at 12:25 am #584938Tony Ash
ParticipantHow do I screen the text I want in the $error[0][‘message’] string, to replace my “Tax Input is required” to “Event Category is required” ?
August 5, 2014 at 12:37 am #585026Tony Ash
ParticipantThe message:
“There was a problem saving your event. The following fields are required:”
is on the event submitted page regardless if there is an error or not.August 5, 2014 at 6:28 pm #591762irishrunner16
ParticipantHey Casey,
Thanks for this snippet. Unfortunately I am encountering the same issue that Tony mentioned above (the error message is displayed immediately after the page is loaded, without the form being submitted). With debug mode on I also am seeing the following above the <b>”There was a problem saving your event. The following fields are required:”</b>.
Notice: Undefined index: type in /wp-content/plugins/the-events-calendar-community-events/tribe-community-events/tribe-community-events.php on line 2158
As with Tony, I’d also appreciate it if you could provide an example of how we can replace a specific error message string with our own (it looks like we’re both looking to replace “Tax Input is required” with “Event Category is required”
Thanks,
SeanAugust 6, 2014 at 8:24 am #596883Casey D
MemberHello all,
We made some updates to prevent these problems. Here is the new code:
https://gist.github.com/caseypatrickdriscoll/3f56502b6ecfb50ae322
You just need to use str_replace() to screen for ‘Tax Input is required’ or any other string you want to replace.
Does this make sense? Let me know if this doesn’t work for you.
Cheers!
– Casey Driscoll
August 6, 2014 at 1:09 pm #598301irishrunner16
ParticipantHey Casey,
Thanks! That seems to be working except for the fact that its causing an issue with the “redirect to a different url after community submission” (its no longer redirecting). How can we get that functioning again?
https://theeventscalendar.com/redirect-to-different-url-after-community-event-submission/August 8, 2014 at 8:28 am #616250Casey D
MemberHello irishrunner16,
Ok I think this is the solution you are looking for.
https://gist.github.com/caseypatrickdriscoll/8b4811d9010dd8d45a8f
And to be clear, (from what I can tell) you won’t be able to have an update message AND a redirect (with php only at least).
The code above redirects on successful create/update (no message), or returns a custom error message.
Am I mistaken there? Does this make sense? Let me know if this doesn’t work for you.
Cheers!
– Casey Driscoll
August 8, 2014 at 1:10 pm #617881irishrunner16
ParticipantThanks Casey! I tested this and it seems to be working now. Appreciate the help in getting this fixed. Have a great weekend!
August 11, 2014 at 9:49 am #640081Casey D
MemberHello irishrunner16,
Happy it worked out!
We’d love it if you would leave us a review and let people know how much you like the plugin! http://m.tri.be/jt
I’ll go ahead and close this thread. Let us know if we can help with anything else.
– Casey Driscoll
September 26, 2014 at 11:47 am #768896Leah
MemberHi there,
I just wanted to let you know that we were able to work on this issue for our upcoming 3.8 release. Keep an eye out on your site for an update announcement! If you update and are still seeing this problem, please post a new thread so we can check it out. Thank you for your patience while we got this fix in place.
Best,
Leah
and the team at Modern Tribe -
AuthorPosts
- The topic ‘Customizing the Required Fields Error Message post-3.7 release’ is closed to new replies.
