[wp-trac] [WordPress Trac] #38891: Profile of wp_password_change_notification does not fit with the do_action( 'after_password_reset', $user, $new_pass );
WordPress Trac
noreply at wordpress.org
Mon Nov 21 20:43:53 UTC 2016
#38891: Profile of wp_password_change_notification does not fit with the do_action(
'after_password_reset', $user, $new_pass );
--------------------------+----------------------
Reporter: jyd44 | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version: trunk
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Changes (by aaroncampbell):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Hey @jyd44,
So the way actions and filters work, the fourth parameter for both
`add_action()` and `add_filter()` is `$accepted_args`, which defaults to
1. So in the case of `add_action( 'after_password_reset',
'wp_password_change_notification' );` that you mentioned, it's saying that
`wp_password_change_notification()` only accepts a single argument. When
`do_action( 'after_password_reset', $user, $new_pass );` is called, it
passes on to `WP_Hook::do_action()` and then to
`WP_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!
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38891#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list