Home › Forums › Backend Issues (wp-admin) › update_field is not working in action hook › Reply To: update_field is not working in action hook
Hello John, was there any more resolution on this?
I am having the same issue. When I run this code from inside a woocommerce hook it does not work, but when I run the same exact code from inside a function on another page that is not run from inside a woocommerce hook it works fine. The last line of code is not updating that particular meta field that I added with ACF. But again the same exact code is working when run outside of a woocommerce hook. Do you have any guidance on this?
$user_id = get_current_user_id();
$user_pickup_location_key = ‘default_pickup_location’;
$subscription_pickup_location_key = ‘subscription_pickup_location’;
$user_default_pickup_location = get_field($user_pickup_location_key, “user_{$user_id}”);
update_field($subscription_pickup_location_key, $user_default_pickup_location, 6369);
Thank you for your time,
Josh
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.