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

Beau Lebens beau at dentedreality.com.au
Tue Nov 23 17:15:35 UTC 2010


I'd love to see something done with this to make it a little more user-friendly.

Option #2 would work for me, and we could even just by default set the
commenter cookies which most themes (including the new built in
comment_form() function) use to prefill the form (after filtering the
values through kses or something like that).

Were you thinking that if a theme didn't add_theme_support() then it'd
still just fall back to the wp_die() approach?

On Tue, Nov 23, 2010 at 2:48 AM, Lazyest Hacker <lazyest at brimosoft.nl> wrote:
> I would support option #2. This is more like how most sites handle incorrect
> forms.
>
> Marcel
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of John
> Blackbourn
> Sent: Tuesday, November 23, 2010 2:33 AM
> To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] Phasing out use of wp_die() for comment errors
>
> 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
>
> _______________________________________________
> 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