Home Forums Front-end Issues Import data to existing field


Import data to existing field

  • Am currently making a function to import template data to my ACF form so the users can save time. The import works but not for pdf/image fields, any solutions are appreciated. The ACF template and offer forms are basically the same.

    The data from the templates are in JSON format in the option value.


    <option value="{&quot;template_name&quot;:&quot;Venue Rabatt&quot;,&quot;venue_name&quot;:&quot;Venue W\u00e4rdshus&quot;,&quot;evenemang&quot;:&quot;festlokal&quot;,&quot;rent&quot;:&quot;6700&quot;,&quot;rent_from&quot;:&quot;08:00:00&quot;,&quot;rent_to&quot;:&quot;18:00:00&quot;,&quot;price_drink&quot;:&quot;350&quot;,&quot;price_drink_discount&quot;:&quot;&quot;,&quot;price_food&quot;:&quot;500&quot;,&quot;price_food_discount&quot;:&quot;340&quot;,&quot;bild&quot;:110,&quot;files&quot;:[{&quot;pdf&quot;:111}]}">Venue Rabatt</option>

    $('#importTemplate').on('change', function() {
            let choice = this.value;
            $.each(jQuery.parseJSON(choice), function(key,val){
                // console.log("key : "+key+" ; value : "+val);
                let el = $('#offerModal').find('div[data-name="'+key+'"]');
    	'new_post'      => [
        	'post_type'     => 'offert',
            'post_status'   => 'publish'
        'field_groups' 		=> ['group_5ee337609a2a9'],
        'submit_value' 		=> __('Send offer', ''),

    ACF Fields/Groups

  • You are trying to set the values of file fields to a post ID that exists in WP. At least if I’m reading what’s being imported correctly. If you want to allow them to supply an ID of a PDF or Image already stored in WP the you’ll need to supply a different type of field and then use the submitted value to update the ACF field manually when then form is submitted.

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

The topic ‘Import data to existing field’ is closed to new replies.