WP Inline Comment Errors plug-in
Improve your comment form user experience by displaying instructions for missing fields directly in the page or post with the comment form. Avoid the WordPress default error screen and customize the appearance of your instructions or error messages.
The WP Inline Comment Errors plug-in enables WordPress to display comment form field errors directly in the page or post that displays the comment form. You can add your own validation functions for author, email, url, comment and custom meta comment form fields and customize the way the error messages or error indications appear. This is a purely PHP solution that does not rely on JavaScript or redirecting the browser to a error message page template.
Visit the WordPress plugin page for this plug-in.
Out of the box and without any configuration, the plug-in will display a list of errors in a manner similar to the above screen shot. If your theme uses the default WordPress generated HTML for the comment form fields, then the plug-in will also show an asterisk as a required mark next to the label of the name, email and comment fields. Try it yourself by submitting an empty comment to this post to see a live example of how the errors and indications display.
Here are some of the features the plug-in supports ‘out of the box’ without any configuration.
- When the user submits a comment with an error, instead of trapping the user on the WordPress default error display, the plug-in automatically redirects the browser back to page with the comment form and scrolls down to the comment form so the user can correct errors and try commenting again.
- Prints a list of comment form field errors in between the form title and first field of the form.
- Shows a required field asterisk next to the label for the name/author, email and comment fields.
- Adds the aria-required attribute to these three fields
- Re-posts the HTTP POST data to the form, so the user does not have to retype all of their comment information.
- If your server does not support cookie based sessions and a user has disabled cookies in their web browser, then the plug-in will redirect the user to the WordPress default error display. You can also create your own customized error message template using the provided example error template.
Suggested theme coding changes
The default configuration should handle most of the basic needs for comment form error display. However there are a few coding changes you should consider.
If your server only supports cookie based sessions then you should create your own customized error message template using the provided example error template. This is for the case that an end user has cookies disabled and the plug-in is unable to use a session to direct the user back to the comment form. The plug-in will instead direct the user to your custom error page, offering a better user experience than the WordPress default error display. Y9u can view the plug-in settings page to determine your PHP session configuration and if you need to create the error template.
You should also add style sheet definitions to make the error messages and required field marks stand out.
Customizing the plug-in
If you need more functionality, the plug-in allows you to customize the error display and behaviors to your liking. Follow the links in the side bar menu for explanation of the functions for the plug-in. You can also review the sample code in the plug-in’s examples folder.
Hello Hayden,
Thanks for your plug-in. However my webpages are Chinese, as soon as I activate the plug-in, the name, email, website and comment characters become funny codes. Would you please tell me how to fix this problem? Thanks!
Sorry for the delay in responding.
It may be that we need a Chinese translation of the plug-in. I’ve recently created a .PO file for poedit software which is a common tool for translating WordPress plug-ins. If someone where interested in translating for Chinese, I could provide this .PO file and the person would then use the poedit software to create a .POT file which contains the translated strings. WP should display these translated strings instead of the English, when a WP site is set to use Chinese language. The process is not difficult if you know the target language. Post another comment here if you want more instructions on how to do this.