I have a Woocommerce site that I want to detect if a user changes any of their billing details. I've had a look around and found this snippet:
add_filter( 'insert_user_meta', function( $meta, $user, $update ) {
if( true !== $update ) return $meta;
$old_meta = get_user_meta( $user->ID );
if( $old_meta[ 'first_name' ] !== $meta[ 'first_name' ] ) {
//* Do something
}
return $meta;
}, 10, 3 );
Will this fire everytime an update is made to the user meta? How can I add in all the following fields to see if any change:
- Company
- Billing address line 1
- Billing address line 2
- City
- Postcode
- Country
- County
Or alternatively, is there a woocommerce hook for this?
Would something like this work?
function my_profile_update( $user_id ) {
if ( ! isset( $_POST['pass1'] ) || '' == $_POST['pass1'] ) {
return;
}
// password changed...
}
add_action( 'profile_update', 'my_profile_update' );