WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 19 months ago

#38336 new enhancement

Login: Add new action hooks to the top of login type forms

Reported by: pagewidth Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6.1
Component: Login and Registration Keywords:
Focuses: Cc:

Description

Currently there are action hooks that fire in the login forms after the fields have been loaded into the form. This allows new fields, new text, additional verfication fields such as CAPTCHA, etc to be added after the username/email/password fields.

However, currently there is not an easy way to add new fields to the top of the forms before the username/email/password fields without building a custom form.

In my use case I require an Account/Membership number to be provided in addition to the email/username, which internally allows the same email address to be used with multiple accounts. The only place to add this new field without building a custom form is to add the field after the password field. The current field sequence on the form appears as email, password, account number. Since the account number field is more significant, it would be better to read the field sequence as: account number, email, password.

In wp-login.php the login forms have the following action hooks:

in form name="registerform" do_action( 'login_form' );

in form name="lostpasswordform" do_action( 'lostpassword_form' );

in form name="registerform" do_action( 'register_form' );

in form name="resetpassform" do_action( 'resetpass_form', $user );

I am requesting new additional action hooks to be created and placed at the top of each of the forms before any fields are defined.

For example, in 'form name="registerform"' a new action hook such as 'do_action( 'login_form_top' )' to appear directly after the form html line as follows:

<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">

<?php

/

  • Fires before the fields are added in the login form. *
  • @since ?????? */

do_action( 'login_form_top' ); <=== new action hook ?>

<p>

<label for="user_login"><?php _e('Username or Email') ?><br /> <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label>

</p>

...

The other forms (lostpasswordform, registerform and resetpassform) would be updated with similar action hooks at the top of each form.

Change History (1)

#1 @pagewidth
19 months ago

The form name 'registerform' was repeated twice. The first instance should be 'loginform' with do_action( 'login_form' ). The four form names are: loginform, lostpasswordform, registerform and resetpassform.

Note: See TracTickets for help on using tickets.