WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 4 months ago

Last modified 3 months ago

#53110 closed enhancement (fixed)

Pass `$userdata` to the actions and filters in `wp_insert_user()`

Reported by: johnbillion Owned by: desrosj
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch needs-dev-note
Focuses: Cc:

Description

There are several actions and filters inside wp_insert_user() which would benefit from being able to access the raw $userdata array that's passed into the function.

One use case is extending the wp user import-csv command in WP-CLI. This command is a wrapper for wp_insert_user() but it's not possible to provide custom user meta fields because there's nowhere inside wp_insert_user() where a plugin can access the raw data array in order to add the user meta.

Change History (6)

This ticket was mentioned in PR #1212 on WordPress/wordpress-develop by johnbillion.


5 months ago

  • Keywords has-patch added; needs-patch removed

#2 @audrasjb
5 months ago

+1 for this proposal. Just figured it out while I was working on #53109.

The PR looks good to me :)

#3 @desrosj
4 months ago

  • Owner set to desrosj
  • Status changed from new to reviewing

#4 @desrosj
4 months ago

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

In 51005:

Users: Pass on the user data received by wp_insert_user() to related hooks.

This adds a new parameter to the action and filter hooks found in wp_insert_user() to pass the raw user data received through $userdata to hooked functions.

This will allow hooked functions to perform more contextual adjustments to new users, and makes supplying custom user meta fields possible.

Props johnbillion, audrasjb.
Fixes #53110.

#5 @milana_cap
4 months ago

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