[wp-trac] [WordPress Trac] #38336: Login: Add new action hooks to the top of login type forms

WordPress Trac noreply at wordpress.org
Tue Jul 20 16:26:30 UTC 2021


#38336: Login: Add new action hooks to the top of login type forms
------------------------------------+------------------------------
 Reporter:  pagewidth               |       Owner:  (none)
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Login and Registration  |     Version:  4.6.1
 Severity:  normal                  |  Resolution:
 Keywords:                          |     Focuses:
------------------------------------+------------------------------
Description changed by sabernhardt:

Old 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.

New 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 verification 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="loginform"
 `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.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/38336#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list