Support

Account

Forum Replies Created

  • SOLVED
    my link is like https://domain/?user=1&parent=165
    i place this code into my page template

     <?php
    if (isset($_GET['user']))
    {
        $user = $_GET['user'];
    } else {
    	$user = '1';
    }
    	acf_form(array(
    	 'id' => 'form',
             'post_id' => 'new_post',
             'field_groups' => array(ID), // Used ID of the field groups here.
             'post_title' => true, // This will show the title filed
             'post_content' => false, // This will show the content field
             'form' => true,
             'new_post' => array(
                 'post_type' => 'customer_data',
    			 'post_author' => $user,  // Where $user_id is a number
                 'post_status' => 'publish' // You may use other post statuses like draft, private etc.
             ),
    		 // 'return' => '/?user=' . $user . '&parent=%post_id%',
             'submit_value' =>__("Submit Addons", 'acf'),
    		 'html_submit_button'  => '<input type="submit" id="next" class="acf-button button button-primary button-large" name="addons_btn" value="%s" />
    		 <input type="submit" id="done" class="acf-button button button-primary button-large" value="Submit Details" style="position: relative; float:right;" />',
         ));
    ?>

    add some JS

    <script type="text/javascript"> 	
    $(document).ready(function(){
    	$("#next, #done").click(function(e) {
    		$("<input />").attr("type", "hidden")
    			.attr("name", "acf[submittype]")
    			.attr("value", e.target.id)
    			.appendTo("#form");
    	});
    });
    </script>

    I also add some code on functions.php

    add_action('acf/submit_form', 'my_acf_submit_form', 10, 2);
    function my_acf_submit_form( $form, $post_id ) {
    	if ($_POST['acf']['submittype'] == 'next') {
    		wp_redirect( 'first_link');
    	} else {
    		wp_redirect('another_link');
    	}
        exit;
    }
  • SOLVED

    i use javascript to set value

    <script type="text/javascript"> 	
    $(document).ready(function(){
    	$.urlParam = function(name){
    		var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    		return results[1] || 0;
    	}
    	$("input[name='acf[%FIELD NAME%]']").val($.urlParam('parent'))
    });
    </script>

    Change “FIELD NAME” with field name like [field_5e8d66375739f]

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