Make WordPress Core

Opened 8 months ago

Closed 7 weeks ago

Last modified 5 weeks ago

#60062 closed defect (bug) (fixed)

Add required attribute to username and password field in wp_login_form function.

Reported by: alesflex's profile alesflex Owned by: audrasjb's profile audrasjb
Milestone: 6.6 Priority: normal
Severity: normal Version: 3.0
Component: Login and Registration Keywords: required-fields has-patch has-testing-info commit needs-dev-note
Focuses: accessibility, template Cc:

Description

Add required attribute to username and password field in wp_login_form function.

Change History (25)

#1 @sabernhardt
8 months ago

  • Keywords required-fields added; changes-requested removed
  • Version trunk deleted

Related: #32510

This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.


5 months ago

#3 @joedolson
5 months ago

  • Keywords needs-patch added
  • Type changed from enhancement to defect (bug)
  • Version set to 3.0

There could be some side-effects to adding this for tools like social sign in, single sign on, etc., but it's worth exploring.

At a minimum, it should be possible to pass the required attribute to the function in the arguments array, even if they aren't added by default.

This will need some testing with extensions that include login mechanisms, particularly those that have any kind of custom bypass or handling.

#4 @joedolson
5 months ago

  • Milestone changed from Awaiting Review to 6.6

#5 @joedolson
5 months ago

  • Owner set to rcreators
  • Status changed from new to assigned

This ticket was mentioned in PR #6352 on WordPress/wordpress-develop by @rcreators.


4 months ago
#6

  • Keywords has-patch added; needs-patch removed

'required_username' and 'required_password' added to defaults. By default, both are set to false. So required attribute will not add to input fields. If set to true in $args for wp_login_form(), it will add the required attribute to the respective input field.

Trac ticket: https://core.trac.wordpress.org/ticket/60062

This ticket was mentioned in Slack in #accessibility by rcreators. View the logs.


4 months ago

@joedolson commented on PR #6352:


3 months ago
#8

E.g.

 *     @type bool   $required_username Whether the username field has the 'required' attribute. Default false.
 *     @type bool   $required_password Whether the password field has the 'required' attribute. Default false.

#9 @rcreators
3 months ago

@joedolson Requested changes has been amended.

This ticket was mentioned in Slack in #accessibility by rcreators. View the logs.


3 months ago

@rcreators commented on PR #6352:


2 months ago
#11

@joedolson Can you check and approve changes?

@rajinsharwar commented on PR #6352:


2 months ago
#12

@Rcreators Added some comments if you can review please.

@rcreators commented on PR #6352:


2 months ago
#13

@Rajinsharwar Requested changes amended.

This ticket was mentioned in Slack in #accessibility by rcreators. View the logs.


2 months ago

#15 @joedolson
7 weeks ago

  • Keywords needs-testing has-testing-info added

Since we've decided to go with adding the arguments only, no extension testing is required. Extenders can choose to add the arguments to their implementations and test at that point. But at least it's now possible to add the required attributes to the login form output.

Testing:

  • Call wp_login_form() with default arguments. Confirm that the input fields are not marked as required.
  • Call wp_login_form() with the required_username and required_password fields set to 'true'. Verify that the input fields have the required attribute.

#16 @rajinsharwar
7 weeks ago

  • Keywords needs-testing removed

I have tested the PR: 6352. And found that:

  1. With none of the required-x argument set: https://prnt.sc/-ez4buphF0Lv
  2. With only 'required_password' => true: https://prnt.sc/sIwfGuvnVvpL
  3. With only 'required_username' => true: https://prnt.sc/4D4WcIftSzKh
  4. With both required-x set: https://prnt.sc/T24XoX0uqUsI

I believe this is good to be committed.

#17 @audrasjb
7 weeks ago

  • Keywords commit added
  • Owner changed from rcreators to audrasjb
  • Status changed from assigned to accepted

Hi there,

Thanks for working on this. The final patch honestly results more in an enhancement than a bugfix. But as it doesn't introduce any change for extenders by default, let's mark it for commit. Self assigning so it can ship before beta 2.

#18 @audrasjb
7 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 58382:

Login and Registration: Add required attribute to username and password fields in wp_login_form().

These attributes are needed to indicate that both fields are required. This changeset doesn't add the attribute by default but allows extenders to enable it by passing true to the $required_username and $required_password to wp_login_form() arguments array.

Props alesflex, sabernhardt, joedolson, rcreators, rajinsharwar.
Fixes #60062.

#19 @audrasjb
7 weeks ago

  • Keywords needs-dev-note added

Adding needs-dev-note so it's mentioned in the Login and Registration devnote or in the Misc Changes devnote.

This ticket was mentioned in Slack in #core by juanmaguitar. View the logs.


5 weeks ago

This ticket was mentioned in Slack in #core by joedolson. View the logs.


5 weeks ago

#23 @joedolson
5 weeks ago

Misc. dev note:

The wp_login_form() function has two new array arguments: required_username and required_password. Passing true to these arguments adds the 'required' attribute to the input fields.

$args = array(
    'required_username' => true,
    'required_password' => true,
);
wp_login_form( $args );

There is no change to the default field output.

This ticket was mentioned in Slack in #core by joedolson. View the logs.


5 weeks ago

#25 @audrasjb
5 weeks ago

Thanks @joedolson for the note.
Added to the draft post.

Note: See TracTickets for help on using tickets.