I've tried everything I can think of and read about. I cannot seem to figure out why this doesn't work, let alone get it to work. I have a Custom post type called Talk. That custom post type has a custom taxonomy (non-hierarchical) of Speaker. The taxonomy Speaker has three Advanced Custom Fields added to it: Institution, Phone, Email.
A Gravity Form using the Advanced Post Creation add-on creates a Talk as a draft. The speaker name, institution, phone and email are all fields on that form. Below is the latest version of my attempts to have the Speaker ACF update after post creation.
add_action( 'gform_advancedpostcreation_post_after_creation_2', 'after_post_creation', 10, 4 ); function after_post_creation( $post_id, $feed, $entry, $form ){ $spkr_inst = rgar( $entry, '3' ); $spkr_ph = rgar( $entry, '10' ); $spkr_em = rgar( $entry, '11' ); $talk_speakers = get_the_terms( $post_id, 'talk_speaker' ); foreach($talk_speakers as $talk_speaker) { $spkr_id = 'speaker_'.$talk_speaker->term_id; GFCommon::send_email( '[email protected]', '[email protected]','','','New Post', $spkr_id); // update_field( 'speaker_institution', $spkr_inst, 'speaker_'.$talk_speaker->term_id); // update_field( 'speaker_phone_number', $spkr_ph, 'speaker_'.$talk_speaker->term_id); // update_field( 'speaker_email_address', $spkr_em, 'speaker_'.$talk_speaker->term_id); } }
The commented out update_field stuff NEVER happens, whether I'm using 'speaker_'.$talk_speaker->term_id
or the above $spkr_id
. But the test email sends, and has the correct $spkr_id value in the email body, speaker_112 ...
I've read through these (but far be it from me to assume I missed nothing ...):
https://www.advancedcustomfields.com/resources/update_field/#update-a-value-from-different-objects
https://docs.gravityforms.com/gform_advancedpostcreation_post_after_creation/#examples