wp_pre_insert_user_data хук-фильтрWP 4.9.0

Filters user data before the record is created or updated.

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

Использование

add_filter( 'wp_pre_insert_user_data', 'wp_kama_pre_insert_user_data_filter', 10, 4 );

/**
 * Function for `wp_pre_insert_user_data` filter-hook.
 * 
 * @param array    $data     Values and keys for the user.
 * @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().
 *
 * @return array
 */
function wp_kama_pre_insert_user_data_filter( $data, $update, $user_id, $userdata ){

	// filter...
	return $data;
}
$data(массив)

Values and keys for the user.

  • user_login(строка)
    The user's login. Only included if $update == false

  • user_pass(строка)
    The user's password.

  • user_email(строка)
    The user's email.

  • user_url(строка)
    The user's url.

  • user_nicename(строка)
    The user's nice name. Defaults to a URL-safe version of user's login

  • display_name(строка)
    The user's display name.

  • user_registered(строка)
    MySQL timestamp describing the moment when the user registered.
    По умолчанию: current UTC timestamp
$update(true|false)
Whether the user is being updated rather than created.
$user_id(int|null)
ID of the user to be updated, or NULL if the user is being created.
$userdata(массив)
The raw array of data passed to wp_insert_user().

Список изменений

С версии 4.9.0 Введена.
С версии 5.8.0 The $userdata parameter was added.

Где вызывается хук

wp_insert_user()
wp_pre_insert_user_data
wp-includes/user.php 2364
$data = apply_filters( 'wp_pre_insert_user_data', $data, $update, ( $update ? $user_id : null ), $userdata );

Где используется хук в WordPress

Использование не найдено.