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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 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.