Home › Forums › Backend Issues (wp-admin) › CF7 posted data to ACF field › Reply To: CF7 posted data to ACF field
*Update*
I successfully create a new post with wp_insert_post function.
The problem now, I can’t store the CF7 data in a specific ACF field. What should I do?
Here’s my current function:
add_action('wpcf7_mail_sent','save_my_form_data_to_my_cpt');
add_action('wpcf7_mail_failed','save_my_form_data_to_my_cpt');
function save_my_form_data_to_my_cpt($contact_form){
$submission = WPCF7_Submission::get_instance();
if (!$submission){
return;
}
$posted_data = $submission->get_posted_data();
$new_post = array();
$new_post['post_title'] = $posted_data['workshop-title'];
$new_post['post_type'] = 'my_custom_post_type';
$new_post['post_content'] = $posted_data['workshop-name'];
$new_post['post_status'] = 'publish';
//When everything is prepared, insert the post into your WordPress Database
$post_id = wp_insert_post($new_post))
return;
}
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.