Home › Forums › Backend Issues (wp-admin) › Saving hidden fields in a custom field › Reply To: Saving hidden fields in a custom field
Hi
after u create front end form pls put following function in your function.php, add the required filed to post
add_filter(‘acf/pre_save_post’ , ‘my_pre_save_post’ );
function my_pre_save_post( $post_id ) {
// check if this is to be a new post
if( $post_id != ‘new’ ) {
return $post_id;
}
$field = $_POST[‘fields’];
$post_title = $_POST[‘fullname’];
$post_content = $field[‘edit_test2’];
$post = array(
‘post_status’ => ‘draft’ ,
‘post_title’ => $post_title,
‘post_content’ => $post_content,
‘post_type’ => ‘page’
);
$newpost_id=wp_insert_post($post);
if($newpost_id!=0)
{
$fullname=$_POST[‘fullname’];
$address=$_POST[‘address’];
add_post_meta($newpost_id,’FullName’, $fullname);
add_post_meta($newpost_id, ‘address’, $address);
}
}
You can also refer following article
http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/
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.