Home › Forums › ACF PRO › how to create front end form data add in post › Reply To: how to create front end form data add in post
@John Huebner . i am sorry for not posting code. actually code post my previous post. thank you so much for your support. it is really great for us.
actually i made ticket support with my site details. but support still not response. it about two days i think.
i change new to new_post all id same now but in front end Form even not come. just come Update Button
<?php acf_form_head(); ?>
<?php
/*
Template Name: Application
*/
get_header(); ?>
<div id="primary">
<div id="content" role="main">
<?php
$args = array(
'field_groups' => array('group_559b4ee335078'), // Field Group name
'post_id' => 'new_post',
'new_post' => array(
'post_type' => 'post',
'post_status' => 'draft'
),
'submit_value' => 'Submit Application'
);
acf_form();
?>
</div>
<!-- #content -->
</div>
<!-- #primary -->
<?php get_footer(); ?>
function.php
function my_pre_save_post( $post_id ) {
// check if this is to be a new post
if( $post_id != 'new_post' ) {
return $post_id;
}
// Create a new post
$post = array(
'post_status' => 'draft' ,
'post_title' => 'A title' ,
'post_type' => 'post',
);
// insert the post
$post_id = wp_insert_post($post);
$category_id = 3; // change this to your category ID
wp_set_post_categories($post_id, array($category), false);
// see WP codex for more information on wp_set_post_categories
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );
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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 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.