[wp-trac] [WordPress Trac] #56028: Pass the user object instead of recall get user function
WordPress Trac
noreply at wordpress.org
Tue Jun 21 21:04:15 UTC 2022
#56028: Pass the user object instead of recall get user function
--------------------------+-----------------------------
Reporter: pbearne | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
IN wp_ajax_send_password_reset we have
{{{#!php
<?php
$user = get_userdata( $user_id );
$results = retrieve_password( $user->user_email );
}}}
then in retrieve_password we have
{{{#!php
<?php
if ( empty( $user_login ) ) {
$errors->add( 'empty_username', __(
'<strong>Error:</strong> Please enter a username or email address.' ) );
} elseif ( strpos( $user_login, '@' ) ) {
$user_data = get_user_by( 'email', trim( wp_unslash(
$user_login ) ) );
if ( empty( $user_data ) ) {
$errors->add( 'invalid_email', __(
'<strong>Error:</strong> There is no account with that username or email
address.' ) );
}
} else {
$user_data = get_user_by( 'login', trim( wp_unslash(
$user_login ) ) );
}
}}}
This patch allows us to pass a user object and bypass the sound call to
find user
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56028>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list