Custom Error Message
-
Are there any error message hooks which I could use to display custom error messages if for e.g when insert of data to database fail?
Currently using:
$result = $wpdb->query($sql); if(!$result) { $wpcf7->skip_mail = true; $error = 'An error has occurred. Please contact the administrator for assistance. <br />Error: '.$wpdb->last_error; $omsg = 'return "'. $error .'";'; add_filter('wpcf7_display_message', create_function('$a', $omsg)); }
that shows the message in green. Any ways to make the message shown on the front end red instead?
-
Use the
wpcf7_form_response_output
filter (found in includes/contact-form.php) to add a class to the response box and in your theme’s stylesheet, add a CSS style rule for the class that makes the message red.Thank you for your response.
I would like to ask how do I use that filter as I am facing some issue trying to use itThis is what I have done which does not work. Would appreciate your guidance here.
$wpcf7->skip_mail = true; $content = __('You have already subscribed to our event.',CURRENT_THEME); $class = 'wpcf7-validation-errors'; $output = sprintf( '<div class="%1$s">%2$s</div>', $class, $content ); add_filter( 'wpcf7_form_response_output', $output, $class, $content, $wpcf7 );
Anyone who knows how to use the filter willing to show some examples on how it is done?
I have found one plugin which is provide admin settings for different error message form different fields.
Means if you have field Name then contact form 7 Provide error message “Please fill required field” , but by using this plugin you can add “Please enter your name”. You can do it without any customization.
Have great experience with this plugin , that to author.
Plugin Link : https://wordpress.org/plugins/cf7-custom-error-messages/
- The topic ‘Custom Error Message’ is closed to new replies.