[wp-hackers] Phasing out use of wp_die() for comment errors

Ryan Bilesky rbilesky at gmail.com
Tue Nov 23 01:37:07 UTC 2010


That does sound much better way to handle comment form errors, I personally
like #2 on your suggestions I think its a clean and user friendly way to
handle this.

On Mon, Nov 22, 2010 at 5:33 PM, John Blackbourn
<johnbillion+wp at gmail.com<johnbillion%2Bwp at gmail.com>
> wrote:

> I'd like to see what people think about replacing wp_die() for comment
> errors with something a bit more graceful.
>
> Here are the three potential errors that can occur when a comment is
> posted:
>
>  * Missing required fields
>  * Duplicate comment detected
>  * Posting comments too quickly
>
> These are currently handled by wp_die(). This isn't a user friendly
> experience as it stops the user dead in their tracks and by default
> they have to use browser navigation to return to where they were.
>
> It is possible to override the wp_die_handler function so themes can
> make this a little more user friendly, but it's still not great. What
> would be ideal would be to return the user to the page they came from
> (in most cases the post permalink) and show a helpful error message
> within context.
>
> What are people's thoughts on how we could go about phasing out using
> wp_die() in this situation? I'm thinking it would be something that a
> theme would add support for. For example:
>
> add_theme_support( 'error-handlers');
>
> That might need a better name, but you get the idea. The theme would
> then handle displaying errors (at the top of the page in a big yellow
> box, for example).
>
> Two ways this could be done:
>
>  1. Redirect the browser back to the post permalink with an error code
> query var appended which maps to a list of predefined, filterable
> error messages (much like the 'message' query var used in the admin
> area).
>  2. Instead of using 'wp-comments-post.php' for the comment form
> action, we could switch to using the post permalink (the form for
> password protected posts uses this). This would allow us to continue
> execution and use the $_POST data to repopulate the comment form
> fields when required fields were missing.
>
> I had a look through Trac to see if anything to do with wp_die() had
> been discussed recently, but didn't spot anything.
>
> Thoughts?
>
> John
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list