I have a Custom Post Type: Talk
The CPT has a Custom Taxonomy (tag): Speaker
The Custom Taxonomy has 3 Advanced Custom Fields: Institution, Phone, Email
The form is to “Add a Talk” and properly creates a draft post, and the Speaker. However I can’t seem to sort out how to take the form fields related to the Speaker Inst/Ph/Em and add them to the Speaker that’s created on submission. Below is what I’m working with (which was throwing fatal errors because I was missing a closing parens … but it’s always something … ) and can’t seem to get it working properly. Any insights greatly appreciated.
add_action( 'gform_after_submission_2', 'update_taxonomy_acf', 10, 2 );
function update_taxonomy_acf( $entry, $form ) {
$post = get_post( $entry['post_id'] );
$talk_speakers = get_the_terms( $post->ID, 'talk_speaker' );
foreach($talk_speakers as $talk_speaker) {
update_field( 'speaker_institution', rgar( $entry, '3' ), $talk_speaker->term_id);
update_field( 'speaker_phone_number', rgar( $entry, '10' ), $talk_speaker->term_id);
update_field( 'speaker_email_address', rgar( $entry, '11' ), $talk_speaker->term_id);
}
}