Support

Account

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

Solving

Multi-select between Gravity Forms & ACF

  • I am using Gravity Forms to allow users to create custom posts with multiple custom fields and using ACF to manage & display those fields.

    Several of these fields are multi-select fields, but it seems that Gravity Forms & ACF handle these fields differently. GF saves each one as a separate custom field with the same name, I don’t know how ACF saves them; I’ll have to test this out, but as for the posts submitted via the form it only shows the one of the multiple select items chosen.

    Any suggestions on how to get these two to work together?

  • @kristarella did you ever find a resolution to this? I’m having the same issue currently.

    Thanks,

    Alan

  • 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);
    	}
    
    }
  • Awesome, thanks @kristarella. I’ll give a try tonight.

    Thanks for responding.

    Alan

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.