My plugin is calling a third party over http whenever a users meta data is updated.

To do this I am using the updated_user_meta hook. It seems however that that hook is called multiple times, once for each piece of meta that is updated.

This means that at the moment my plugin is making several http calls.

So is there a way to know which is the last piece of meta data updated. So I can make the call once at that point? Or should I be doing this a different way?

FYI I can't use profile_updated because it doesn't always get called.

A practical example: I am keeping my users in sync with a Mailchimp list. In that list I have extra custom fields that match their wordpress meta data fields of Users Role, Organisation ID and Organisation name.

When these details are updated updated_user_meta is called three times, once for each of the pieces of meta data. So at the moment I am making three calls to Mailchimp once for each of them because I can't find another hook that is called when the last piece of meta data is updated.

1 Answer 1


If you can assume that user profile is edited all at once (Users Role, Organisation ID and Organisation name), you can hook on only one meta_key (say Organisation name) and send all infos at this moment. By the time this action is fired, all 3 metas are already in database.

add_action('updated_user_meta', 'when_user_meta_updated', 10, 3);

function when_user_meta_updated( $meta_id, $object_id, $meta_key, $_meta_value ) {
    // we do this only on one meta not all three    
    if ($meta_key == 'organisation_name' ) {
            $organisation_name = $_meta_value;
            // get other fields from db
            $user_role         = get_user_meta( $object_id, 'user_role', true );
            $organisation_ID   = get_user_meta( $object_id, 'organisation_id', true );

            // HTTP Call

  • Yeah I'm doing exactly that but trying to capture several meta changes. So this function is running several times. But I only want to make one http call.
    – mattl
    Feb 11, 2015 at 11:22
  • i am not sure to understand, could you give a practical example ? When do you need to make your http call ? Feb 11, 2015 at 11:27
  • have added an example
    – mattl
    Feb 11, 2015 at 11:34
  • That would be perfect in this situation. I have another situation where it is calling the same meta_key up to three times. But for now this fulfils the question. Thanks for your time.
    – mattl
    Feb 11, 2015 at 21:51
  • Nice ! Well if you need to get deeper with this, updated_user_meta is probably not the best hook to sync with an external service like Mailchimp. Consider using a cron task maybe ? Feb 11, 2015 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.