Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#53338 new enhancement

Determine when there is an error submitting the wp-signup.php form

Reported by: henry.wright Owned by:
Priority: normal Milestone: Awaiting Review
Component: Networks and Sites Version:
Severity: normal Keywords:
Cc: Focuses: multisite

Description

For both the wp-signup.php user and blog forms there doesn't seem to be a way to determine if an error occurred in the form submission aside from error text being displayed above the form.

If a body class of something like error is added or something like error=true is appended to the query string then developers will be able to perform actions or style the page easier.

Change History (1)

#1 @realloc
3 months ago

I think marking the form itself is the cleanest option here.

Form level marker (preferred): The <form id="setupform"> elements render inside signup_user(), signup_blog() and signup_another_blog(), after the validate_* functions have determined has_errors(). So the state is known there, and we can add a class and/or data attribute directly, e.g. class="wp-signup-error" or data-has-error="true", ideally via a filter. Server side, works without JS, comes back with the POST result, no restructuring. A hidden field like name="error" I would avoid, since it gets resubmitted on the next POST.

Body class: body.wp-signup-error has wider reach, but <body> is output by get_header() before the error is known. It would require buffering the form processing ahead of the header, which changes the order of some actions (preprocess_signup_form, the network admin notice) relative to wp_head and risks breaking plugins. Only worth it if that reach is really needed.

Query string: I would drop error=true. It needs a Post/Redirect/Get flow that loses the entered values unless persisted first. Too large for this.

Question: Does a form level class plus data attribute cover the use cases, or is a page wide body class needed?

Note: See TracTickets for help on using tickets.