Support

Account

Home Forums Backend Issues (wp-admin) Multi-select between Gravity Forms & ACF Reply To: Multi-select between Gravity Forms & ACF

  • Yes, but unfortunately it is “manually” reformatting each field. I.e., you have to add your dropdown fields to the list in this function and then it iterates over them to put them in the right format.

    add_action('gform_after_submission_14', 'reformat_multiselect', 10, 2);
    function reformat_multiselect($entry, $form) {
    
    	$post_id = $entry['post_id'];
    	$selects = array(
    		'custom_field1' => 'ACF_field_key',
    		'custom_field2' => 'ACF_field_key',
    		'custom_field3' => 'ACF_field_key'
    	);
    
    	foreach ($selects as $name => $key) {
    		$custom = get_post_meta( $post_id, $name, false );
    		delete_post_meta( $post_id, $name );
    
    		$value = maybe_serialize($custom);
    
    		if (function_exists('update_field'))
    			update_field($key,$value,$post_id);
    		else
    			add_post_meta($post_id,$key,$value);
    	}
    
    }