Opened 8 years ago
Closed 8 years ago
#38891 closed defect (bug) (invalid)
Profile of wp_password_change_notification does not fit with the do_action( 'after_password_reset', $user, $new_pass );
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
In wp-includes/pluggable.php, the function wp_password_change_notification
is declared as: function wp_password_change_notification( $user )
in wp-includes/default_filters.php, line 369, the action is added as:
add_action( 'after_password_reset', 'wp_password_change_notification' );
in wp-includes/user.php, line 2228, the action 'after_password_reset' is called as:
do_action( 'after_password_reset', $user, $new_pass );
Is it possible to clarify.
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hey @jyd44,
So the way actions and filters work, the fourth parameter for both
add_action()
andadd_filter()
is$accepted_args
, which defaults to 1. So in the case ofadd_action( 'after_password_reset', 'wp_password_change_notification' );
that you mentioned, it's saying thatwp_password_change_notification()
only accepts a single argument. Whendo_action( 'after_password_reset', $user, $new_pass );
is called, it passes on toWP_Hook::do_action()
and then toWP_Hook::apply_filters()
, which slices the arguments array to the size originally specified (in this case 1).Since
wp_password_change_notification()
only needs$user
, that's all that gets sent to it. If you wanted your own function to be able to make use of both arguments that get passed, then when you call add_action, you just need to pass 2 as the fourth parameter:add_action( 'after_password_reset', 'your_password_related_function', null, 2 );
I hope that clears things up!