insert_custom_user_meta
Filter HookDescription
Filters a user's custom meta values and keys immediately after the user is created or updated and before any user meta is inserted or updated. For non-custom meta fields, see the {@see 'insert_user_meta'} filter.Hook Information
File Location |
wp-includes/user.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2547 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$custom_meta
|
Array of custom user meta values keyed by meta key. |
WP_User
|
$user
|
User object. |
bool
|
$update
|
Whether the user is being updated rather than created. |
array
|
$userdata
|
The raw array of data passed to wp_insert_user(). |
Usage Examples
Basic Usage
<?php
// Hook into insert_custom_user_meta
add_filter('insert_custom_user_meta', 'my_custom_filter', 10, 4);
function my_custom_filter($custom_meta, $user, $update, $userdata) {
// Your custom filtering logic here
return $custom_meta;
}
Source Code Context
wp-includes/user.php:2547
- How this hook is used in WordPress core
<?php
2542 * @param array $custom_meta Array of custom user meta values keyed by meta key.
2543 * @param WP_User $user User object.
2544 * @param bool $update Whether the user is being updated rather than created.
2545 * @param array $userdata The raw array of data passed to wp_insert_user().
2546 */
2547 $custom_meta = apply_filters( 'insert_custom_user_meta', $custom_meta, $user, $update, $userdata );
2548
2549 $meta = array_merge( $meta, $custom_meta );
2550
2551 if ( $update ) {
2552 // Update user meta.
PHP Documentation
<?php
/**
* Filters a user's custom meta values and keys immediately after the user is created or updated
* and before any user meta is inserted or updated.
*
* For non-custom meta fields, see the {@see 'insert_user_meta'} filter.
*
* @since 5.9.0
*
* @param array $custom_meta Array of custom user meta values keyed by meta key.
* @param WP_User $user User object.
* @param bool $update Whether the user is being updated rather than created.
* @param array $userdata The raw array of data passed to wp_insert_user().
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/user.php
Related Hooks
Related hooks will be displayed here in future updates.