I’ve looked into it again and wp_user_meta()
is just a wrapper for get_metadata()
which caches its results.
I suspect you have made your user edits earlier in the exection of the request, then later in the execution you want to send this email.
You can bust the cache by putting this at the top of your email call:
update_meta_cache( 'user', $user_id );
Please accept my answer on SO too 馃檪
Does the NEXT email after that show the updated previous data?
e.g.
Attempt #1:
Original DB value: 123
Updated value: 567
Email sends: 123
Attempt #2
Original DB value: 567
Updated value: 999
Email sends: 567
Have you tried using get_user_meta directly?
get_user_meta($user_id, 'field_5b7e4f388fd11', $single=true);
Maybe that will work around the weirdness.
Here is the documentation for get_user_meta().
Are you saying that, given your example, in the Edit Product screen for “Product 1” there would be a field with the text “Open”? And this field is set to the company_status field of an associated company?
If that’s the case, I would do something like this:
1. Associate Products to Companies (already done).
2. Create a “company_status” field on Company cusotm post type.
3. Create a “product_company_status” field on Product custom post types.
4. Use the update_value hook to detect the Company’s company_status field getting updated. See the Update_value() documentation.
5. In the hook function, find all products that are associated with that company. Then loop over all Products and update the “product_company_status” field with the new “company_status”. See the update_field() documentation.
Now whenever a “Company” post’s has it’s company_status value updated, the hook function will fire, updating all products. I hope that makes sense.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.