Home › Forums › General Issues › How to show custom field inputs on acf_form() front end when creating new post › Reply To: How to show custom field inputs on acf_form() front end when creating new post
Hi ch1n3s3b0y
In its front page you should put something like:
<?php
acf_form(array(
'post_id' => 'new_post_emp',
'field_groups' => array( 86 ),
'return' => add_query_arg( 'updated', 'true', "http://qgbrain.com.br/web/assesstment/pesquisar-empresa/" ),
));
?>
In the function.php you should put:
<?php
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
if( $post_id == 'new_post_emp' ) {
// data send by POST in form
$title = $_POST['fields']['field_552b299a1844c'];
// Default data post
$post = array(
'post_status' => 'Publish',
'post_type' => 'processos',
'post_title' => '0000 |'.$title,
);
// action for update
$post_id = wp_insert_post( $post );
}
}
?>
this way the created form is available on your front-end
I hope it helped
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.