0

I am using PODS to add info to a users profile. I want to add data to the usermeta then do something with it right away. One the fields created by PODS is 'estimated_delivery_date'. I have simplified the code as show below.


 add_action( 'profile_update', 'initiate_participant_profile_update', 10, 2 );
     function initiate_participant_profile_update( $user_id, $old_user_data ) { 
     $estDD = get_user_meta( $user_id, 'estimated_delivery_date', true );
     $pathBodyFile = dirname(__FILE__) . "/$user_id" . "ParticipantData.txt";
     $fileBody = fopen($pathBodyFile, "a");
     echo fwrite($fileBody, "Estimated Delivery Date: $estDD\n\n");
     fclose($fileBody); 
    }

When I add the info using the Update User profile page $estDD does not appear in the file. But if I go back to the edit profile page and hit Update User again, boom, there it is.

So I am surmising the the action is running before the usermeta is updated. How can I fix this?

0

Not long after posing this question I figured it out. But since I had spent a few hours looking for the awswer I thought maybe it would be worth posting. I hope this does not break any rules. I changed the default priority from 10 to 11. as per:

 add_action( 'profile_update', 'initiate_participant_profile_update', 10, 2 );

changed to

 add_action( 'profile_update', 'initiate_participant_profile_update', 11, 2 );

So I guess the new function now waits for the user update to finish be fore running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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