Book a Free Call

WP | Gravity Forms | Change error message text



I was recently tasked with changing some Gravity Forms content over to a different language. I have to say, it was a little odd.

Gravity Forms uses hooks to update certain core parts, seemingly. So you can’t just change the error message in the form settings itself.

So here’s what you do:

Firstly, get access to your functions.php file or use a plugin (such as Snippets – if you are unfamiliar I would recommend this plugin as it saves you from killing your site with errors in the functions file).

Next, get the ID of your form. It’s listed when you view all forms. My form ID is 2

Then add the ID to the end of the filter name, like this: gform_validation_message_2

Finally, use the filter below, making sure to use the correct ID in the first line. This way you will target just the form you are looking to target

add_filter("gform_validation_message_2", "change_message", 10, 2);
function change_message($message, $form){
  return "<div class='validation_error'>This is your new error message</div>";
}

Okay hope that helps someone!

Need rapid website development:

For smaller projects at high speed


  • Adding script tag embed to Gatsby component

    Read More
  • Get more than 100 queries in GraphQL (I felt stupid)

    Read More
  • Animate on Scroll (AOS) into Nuxt js

    Read More
  • WordPress Super-admin hack

    Read More
  • Add content or ACF field under thumbnail/image gallery in Woocommerce

    Read More

Tags


Categories

Is it urgent? Donate to Cork Simon

Got an urgent issue?

Charlie's Cottage, Carrigrohane, Co. Cork, T12 WY9H

(085) 7686677