I have this pseudo code I'm writing to compare the user meta values. I have some user meta that will hold a null value until the user update his account, before the values are updated I need to check if they differ otherwise I want to leave them untouched inside the wp database. My idea is to get the user meta, loop them and do the comparision. In my case I can have a meta value named shipping_address and another that will hold the updated info that can be named new_shipping_values.

What can be a good solution?

                $stored_user_meta = get_user_meta( $user_id );
                $user_meta = array();
                foreach( $stored_user_meta as $key ){
                    foreach( $key as $val ){
                      //check the array values and use only updated info

Thank you for the suggestions

1 Answer 1


So you need to check if the values for a single user meta field are different or the same as the new values?

If so, you don't need to check the current values. Simply update the meta field regardless. It will be slower to check the current values and there is no benefit to doing so and the result is the same.

  • The main problem is that I will need to give to moderators the ability to check the data before any account can be re-approved after modifications. This is why I need to implement a check.
    – ICTDEV
    Oct 30 at 10:06

Your Answer

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

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