I am using APC Add-On with Gravity forms for users to submit content. When they submit the form it creates a post in a CPT with pending status. All of that works just fine with no issues. I’m using ACF on the CPT to determine the style when these posts are queried on the front end of the website. In short, the GF form has a dropdown with options 1, 2, or 3, and on the CPT post, there is an ACF dropdown that mirrors those options. I want APC Add-On to update the ACF. But the add-on only updates custom fields.
I found and tried to implement this article but I’m still at a loss and need some help.
When I submit the form the ACF is not updated.
https://docs.gravityforms.com/advanced-post-creation-add-on-using-third-party-post-types/
I’ve commented out a lot in this code just as I was working and trying to make things happen. Any help you can offer will be greatly appreciated.
add_action( 'gform_advancedpostcreation_post_after_creation_2', 'apc_serialize_select', 10, 4 );
function apc_serialize_select( $post_id, $feed, $entry, $form ) {
// selection field id.
$field_id = 8;
// Get field object.
$field = GFAPI::get_field( $form, $field_id );
// field Key
//$field_key = field_61fec25683947;
if ( $field->type == 'select' ) {
// Get a comma separated list of selections checked
$selected = $field->get_value_export( $entry, $field_id, true );
// Convert to array.
$values = explode( ', ', $selected );
//$value = array();
}
// Replace my_custom_field_key with your custom field meta key.
//update_post_meta( $post_id, $field_key, $values );
update_field('field_61fec25683947', $values, $post_id);
}