Advanced Post Creation Add-On mapped to ACF on Post Creation

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);
}


Justin, the APC add-on doesn’t provide any built-in integration or support for ACF. Which means that if ACF expects the value saved in a format different from the one GF is using (plain text), ACF wouldn’t recognize the value.

Using the gform_advancedpostcreation_post_after_creation hook you can update values to convert them to the expected ACF format with your own custom code.

The snippet example you found would work only to when ACF expects the value saved as a serialized object, this has been proven to work for example to map GF checkboxes to ACF checkboxes.

To use the gform_advancedpostcreation_post_after_creation hook successfully you would need to know first how ACF is expecting the value for the drop down. I don’t have that information, I would recommend you to check it with ACF support.

For a drop down field, GF would just save the value for the choice as plain text.

There’s also a third-party add-on that maybe could help if you’re unable to find a way to resolve this using code: ACF Feeds for Gravity Forms – WordPress plugin | WordPress.org

Hey Samuel, I am using that hook (see code above) and I am also using the update_field() function which is an ACF function. I can’t be the first person to try and make APC and ACF work together lol. I feel like I’ve got 95% of it figured out just can’t cap off that last 5%. Thank you for your comment and any further assistance that you may provide.

Popping back on here to make sure this doesn’t get closed. I still need help trouble shooting this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.