I’m new to using ACF form and trying to create a form for users to submit a post using a shortcode. I don’t particularly want to use a page template. The fields are an image field and 5 text fields. I am trying to display a success message once the form is submitted but I keep running into problems no matter what I try.
This is my current code:
function toyw_gallery_item_form_handler() {
// Load ACF form header
acf_form_head();
ob_start();
// ACF Form settings
$settings = array(
'id' => 'gallery_form',
'post_id' => 'new_post',
'post_title' => false,
'new_post' => array('post_type' => 'gallery-item', 'post_status' => 'pending'),
'field_groups' => array('group_66acdfbecde2d'),
'submit_value' => __("Submit", 'acf'),
'form_attributes' => array('class' => 'gallery_form'),
'html_submit_button' => '<input type="submit" class="acf-button button kb-button kt-button kt-btn-size-standard kt-btn-width-type-auto kb-btn-global-inherit" value="%s" />',
);
// Render the form
acf_form($settings);
return ob_get_clean();
}
When I add return => ” the form clears but no message is displayed, if I try to redirect to a different page I get the error of “cannot modify header information”. I’ve tried adding the arguments for updated_message and html_updated_message but this doesn’t work either. I’ve also tried to redirect using ‘acf/save_post’ instead but get the header information error again.
I am on WP 6.6.1 and using Kadence with a child theme.