Customizing the Required Fields Error Message post-3.7 release

Home Forums Calendar Products Community Events Customizing the Required Fields Error Message post-3.7 release

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #561571
    irishrunner16
    Participant

    Hi 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,
    Sean

    #574155
    Tony Ash
    Participant

    Same issue here…

    #578684
    Casey D
    Member

    Hello 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

    #582466
    Casey D
    Member

    Hey 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

    #584938
    Tony Ash
    Participant

    How 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” ?

    #585026
    Tony Ash
    Participant

    The 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.

    #591762
    irishrunner16
    Participant

    Hey 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,
    Sean

    #596883
    Casey D
    Member

    Hello 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

    #598301
    irishrunner16
    Participant

    Hey 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/

    #616250
    Casey D
    Member

    Hello 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

    #617881
    irishrunner16
    Participant

    Thanks Casey! I tested this and it seems to be working now. Appreciate the help in getting this fixed. Have a great weekend!

    #640081
    Casey D
    Member

    Hello 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

    #768896
    Leah
    Member

    Hi 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

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Customizing the Required Fields Error Message post-3.7 release’ is closed to new replies.