wppaste
WordPress

apply_filters( 'wp_pre_insert_user_data', array $data, bool $update, int|null $user_id, array $userdata )

Since
4.9.0, 5.8.0
Filters user data before the record is created or updated.

Description

It only includes data in the users table, not any user metadata.

Compatibility

WordPress
since 5.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$dataarray
{ Values and keys for the user.
@type string $user_login The user's login. Only included if $update == false @type string $user_pass The user's password.
@type string $user_email The user's email.
@type string $user_url The user's url.
@type string $user_nicename The user's nice name. Defaults to a URL-safe version of user's login.
@type string $display_name The user's display name.
@type string $user_registered MySQL timestamp describing the moment when the user registered. Defaults to the current UTC timestamp.
}
  • $user_loginstring

    The user's login. Only included if $update == false @type string $user_pass The user's password.
  • $user_emailstring

    The user's email.
  • $user_urlstring

    The user's url.
  • $user_nicenamestring

    The user's nice name. Defaults to a URL-safe version of user's login.
  • $display_namestring

    The user's display name.
  • $user_registeredstring

    MySQL timestamp describing the moment when the user registered. Defaults to the current UTC timestamp.
$updatebool
Whether the user is being updated rather than created.
$user_idint|null
ID of the user to be updated, or NULL if the user is being created.
$userdataarray
The raw array of data passed to wp_insert_user().

Where this hook fires · 1

  • wp-includes/user.php:2410wp_insert_user()

Source code

	 *                                   the current UTC timestamp.	 * }	 * @param bool     $update   Whether the user is being updated rather than created.	 * @param int|null $user_id  ID of the user to be updated, or NULL if the user is being created.	 * @param array    $userdata The raw array of data passed to wp_insert_user().	 */	$data = apply_filters( 'wp_pre_insert_user_data', $data, $update, ( $update ? $user_id : null ), $userdata ); 	if ( empty( $data ) || ! is_array( $data ) ) {		return new WP_Error( 'empty_data', __( 'Not enough data to create this user.' ) );	} 	if ( $update ) {

Changelog

Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.8.0
The $userdata parameter was added.from the docblock
4.9.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.