Home › Forums › Add-ons › Flexible Content Field › Update number field by adding new CPT action › Reply To: Update number field by adding new CPT action
Thanks for your answer John.
I’m updating this post because I find a way to accomplish my goal :
public function update_credits_acf( $post_id ) {
$post_id = 137; // post_id of my CPT post
$number_of_credits_available = get_field('credits_available', $post_id);
$number_of_credits_action = get_field('number_of_credits');
$number_of_credits_left = $number_of_credits_available - $number_of_credits_action;
update_field('credits_available', $number_of_credits_left, $post_id);
This code works, now my question is : How to dynamically retrieve the id of my CPT ? I have several posts so I can’t let “$post_id = 137;”.
I tried some actions with get_the_ID(), the_ID()…
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.