Make WordPress Core

Opened 14 months ago

Closed 10 months ago

Last modified 10 months ago

#57843 closed enhancement (fixed)

Add action to wp_update_user

Reported by: tanner-m's profile tanner m Owned by: audrasjb's profile audrasjb
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch needs-testing add-to-field-guide has-dev-note
Focuses: Cc:

Description

Add an action to the end of the wp_update_user function that includes the data set to be updated. I am working on SSO and several places use this function to set the user's password. I've included the processed data and added a new $userdata_raw variable to pass the unprocessed data as well.

I've also added added a comment to wp_insert_user to clarify what type of password should be passed there. Based on the current doc block, it is unclear that the password passed to wp_insert_user should be hashed if calling the function directly to update an existing user.

Attachments (3)

wp_update_user.patch (1.6 KB) - added by tanner m 14 months ago.
wp_update_user.2.patch (1.6 KB) - added by tanner m 14 months ago.
Update typo in original doc block.
wp_update_user_action.patch (1.6 KB) - added by tanner m 14 months ago.
Just remembered @since goes above the @params

Download all attachments as: .zip

Change History (19)

@tanner m
14 months ago

Update typo in original doc block.

@tanner m
14 months ago

Just remembered @since goes above the @params

This ticket was mentioned in Slack in #core by tanner. View the logs.


14 months ago

#2 @desrosj
14 months ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 6.3

Hey @tanner-m!

Thanks for this one. I'm really surprised this has not been requested in the past. I did some searching, but wasn't able to find a duplicate ticket.

Moving this to the 6.3 milestone so it can get a review.

#3 @lphoumpakka
12 months ago

Hi,

The patch works as expected.

You need to update an user and check $user_id, $userdata, $userdata_raw are available.

You can use this snippet :

<?php
add_action( 'wp_update_user', function ( $user_id, $userdata, $userdata_raw ) {
        echo $user_id;
        print_r( $userdata );
        print_r( $userdata_raw );
        die;
}, 10, 3 );

#4 @oglekler
10 months ago

  • Keywords has-testing-info added

It is simple enough patch, it still has a time to be in trunk until Beta 1. @since will need to be changed if this patch is going into 6.3.

#5 @oglekler
10 months ago

  • Keywords needs-testing added; has-testing-info removed

#6 @oglekler
10 months ago

Hi @tanner-m and @desrosj, I think @since should be updated and arrays descriptions before and after update can be a bit clearer.

	 * @param int   $user_id      The ID of the user that was just updated.
	 * @param array $userdata     The array of user data that was updated.
	 * @param array $userdata_raw The unedited array of user data that was updated.
  • These 'was updated' are a bit confusing.

#7 @audrasjb
10 months ago

  • Keywords needs-dev-note added

#10 @audrasjb
10 months ago

PR4704 refreshes the previous patch against trunk.

This ticket was mentioned in Slack in #core by chaion07. View the logs.


10 months ago

#12 @audrasjb
10 months ago

  • Owner set to audrasjb
  • Resolution set to fixed
  • Status changed from new to closed

In 56071:

Users: Introduce the wp_update_user action.

This changeset introduces the wp_update_user action hook, which fires after the user has been updated and emails have been sent.

Props tanner-m, desrosj, lphoumpakka, oglekler, audrasjb, azzaoz.
Fixes #57843.

@audrasjb commented on PR #4704:


10 months ago
#13

merged

#14 @stevenlinx
10 months ago

  • Keywords add-to-field-guide added

#16 @stevenlinx
10 months ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.