Home › Forums › Front-end Issues › Multi Submit Button With Different Return
Hello, i need a help for my frontend form.
01.I need to set multi submit button, but for different “return” redirect link.
02. How can i get Field Value from my url link ?
Ex. http://www.domain.com/?id=”xxx” > Get Value from a field_name ( not the post title ) base on this ID, and set as default value on field_name into new submission.
Thank you.
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;
}
The topic ‘Multi Submit Button With Different Return’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.