insert_user_meta

Filters a user's meta values and keys before the user is created or updated.

Description

apply_filters( 'insert_user_meta', (array) $meta, (WP_User) $user, (bool) $update ); 

Does not include contact methods. These are added using wp_get_user_contact_methods( $user )..

Parameters (3)

0. $meta (array)
1. $user (WP_User)
User object.
2. $update (bool)
Whether the user is being updated rather than created.

Usage

To run the hook, copy the example below.
  1. $meta = apply_filters( 'insert_user_meta', $meta, $user, $update ); 
  2.  
  3. if ( !empty( $meta ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the insert_user_meta callback 
  2. function filter_insert_user_meta( $meta, $user, $update ) { 
  3. // make filter magic happen here... 
  4. return $meta
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'insert_user_meta', 'filter_insert_user_meta', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'insert_user_meta', 'filter_insert_user_meta', 10, 3 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/user.php  
  1. $meta = apply_filters( 'insert_user_meta', $meta, $user, $update );