Home › Forums › Front-end Issues › Schedule Post with Frontend Form? › Reply To: Schedule Post with Frontend Form?
The first thing you need to do is move acf_form_head();
to before get_header();
http://www.advancedcustomfields.com/resources/acf_form/
Then in functions.php
add_filter('acf/pre_save_post' , 'shareable_pre_save_post', 10, 1 );
function shareable_pre_save_post($post_id) {
// check if this is to be a new post
if ($post_id != 'new_shareable') {
return $post_id;
}
// The date picker field
// change field_563657f49b4d9 to the field key of your date field
$postdate = date('Y-m-d H:i:s', strtotime($_POST['acf']['field_563657f49b4d9']));
// Create a new post
$post = array(
'post_type' => 'shareable',
'post_title' => $_POST['acf']['_post_title'],
'post_status' => 'future',
'post_date' => $postdate
);
// insert the post
$post_id = wp_insert_post( $post );
// return the new ID
return $post_id;
}
Then in your template where you want to show the form
$args = array(
'post_id' => 'new_shareable',
'post_title' => true,
'field_groups' => array(3498), // change to ID of the field group to show
'submit_value' => 'Create post'
);
acf_form($args);
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.