Home › Forums › Front-end Issues › Multi Submit Button With Different Return › Reply To: Multi Submit Button With Different Return
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;
}
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
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.