[wp-trac] [WordPress Trac] #38334: Login: Pass the `$user_data` object as a parameter to the `lostpassword_post` hook

WordPress Trac noreply at wordpress.org
Mon Oct 17 17:38:38 UTC 2016


#38334: Login: Pass the `$user_data` object as a parameter to the
`lostpassword_post` hook
------------------------------------+-----------------------------
 Reporter:  pagewidth               |      Owner:
     Type:  enhancement             |     Status:  new
 Priority:  normal                  |  Milestone:  Awaiting Review
Component:  Login and Registration  |    Version:  4.6.1
 Severity:  normal                  |   Keywords:
  Focuses:                          |
------------------------------------+-----------------------------
 In function 'retrieve_password()' in 'wp-login.php', the
 'lostpassword_post' action hook does not allow access to the $user_data
 object to do any validation/error checking or make any changes to the user
 information.

 In my use case I store an account/membership id in the user's profile
 email address field in order to allow the same email address to be used
 for different account/membership ids, then remove the account/membership
 id from the email address before sending the email.

 In the 'retrieve_password()' function, the email address is saved in the
 local variable:
    $user_email = $user_data->user_email;

 Then this local variable is used to send the email later in:
    if ( $message && !wp_mail( $user_email, wp_specialchars_decode( $title
 ), $message ) )

 There is currently no way to change the local variable copy of the email
 address '$user_email' either via the above action hook, or the two filter
 hooks before sending the email:

    $title = apply_filters( 'retrieve_password_title', $title, $user_login,
 $user_data );
    $message = apply_filters( 'retrieve_password_message', $message, $key,
 $user_login, $user_data );

 I am requesting changing the line:
    do_action( 'lostpassword_post', $errors );
 to:
    do_action( 'lostpassword_post', $errors, $user_data );

 This will allow any changes to the $user_data information and/or further
 validation/error checks using the user information, which will also allow
 any changes to be copied to the $user_email local variable.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38334>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list