Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#61541 closed enhancement (fixed)

wp_set_password hook lacks previous context

Reported by: dd32's profile dd32 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.7 Priority: normal
Severity: normal Version: 6.2
Component: Users Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

In #57436 a hook was added to wp_set_password, but unlike the other user-related hooks, this hook doesn't pass the previous state of the user as context to the hook.

Adding additional context, either as the fields that have been modified, or as a full WP_User would be appreciated for logging and authentication plugins.

<?php
$old_user_data = array( 'user_pass' => ...., 'user_activation_key' => ... );
or
$old_user_data = get_user_by( ... )

// perform user update; $wpdb->update()

do_action( 'wp_set_password', $password, $user_id, $old_user_data );

Change History (4)

This ticket was mentioned in PR #6948 on WordPress/wordpress-develop by @dd32.


5 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Similar to other user hooks that pass the previous user state, this adds the previous user state to the wp_set_password hook.

This passes the full user details, rather than only the changed details, for consistency with other hooks.

Trac ticket: https://core.trac.wordpress.org/ticket/61541

#2 @SergeyBiryukov
5 weeks ago

  • Milestone changed from Awaiting Review to 6.7
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#3 @SergeyBiryukov
5 weeks ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 58653:

Users: Pass the previous state of the user as context to the wp_set_password hook.

Follow-up to [55056], [55250].

Props dd32.
Fixes #61541.

@SergeyBiryukov commented on PR #6948:


5 weeks ago
#4

Thanks for the PR! Merged in r58653.

Note: See TracTickets for help on using tickets.