profile_update action triggers twice
-
When I hook into the profile_update action and edit a field in wp-admin, the function runs twice. On the first trigger $userdata doesn’t have the updated information. When I deactivate lifterlms it goes back to only triggering once. When I activate lifterlms it only triggers once on the first field edit and $userdata is proper. Then on the second field edit it goes back to triggering twice.
This is annoying because I’m trying to use that data to synchronize with an external system and on the second trigger the API call doesn’t seem to be going through. Ok maybe I can skip the API call on the first trigger to make sure it runs on the second trigger, but if that second trigger ever stops happening then our systems are going to get out of sync. Is this second trigger intended behavior?
function custom_function( $user_id, $old_user_data, $userdata ) {
$email = $userdata['user_email'];
$first_name = $userdata['first_name'];
$last_name = $userdata['last_name'];
error_log( print_r( $email, true ) );
error_log( print_r( $first_name, true ) );
error_log( print_r( $last_name, true ) );
}
add_action( 'profile_update', 'custom_function', 10, 3 );
- You must be logged in to reply to this topic.