Home › Forums › General Issues › Using acf_form – add post title… › Reply To: Using acf_form – add post title…
rdck, I’ve done what you said:
‘post_title’ => $_POST[‘fields’][‘field_5344021b6851b’],
Mine was:
$_POST[‘fields’][‘nome_do_evento’],
And it doesn’t work.
Can you figure it out on my functions.php?
// Create the frontend form
function my_pre_save_post( $post_id ) {
if ( $post_id != 'new' ) {
return $post_id;
}
$post = array(
'post_status' => 'draft',
'post_title' => 'teste', $post_title, $_POST['nome_do_evento']['value'],
'post_type' => 'post'
);
$post_id = wp_insert_post($post);
$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
And the page.php :
<?php $acf = array(
'post_id' => 'new',
'field_groups' => array(15),
'submit_value' => 'ENVIAR'
); ?>
<?php acf_form($acf); ?>
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.