Skip to content

Commit b038cae

Browse files
author
Ariel Jolo
committed
First stab at getting Contact 7 > ACF integration
1 parent 03af363 commit b038cae

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

themes/osi/functions.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,26 @@ function osi_wpdc_comment_body( string $comment_body ) {
425425
return $trimmed_comment_body;
426426
}
427427
add_filter( 'wpdc_comment_body', 'osi_wpdc_comment_body', 10, 1 );
428+
429+
430+
431+
/**
432+
*
433+
* Create a new Supporter CPT.
434+
*
435+
*/
436+
add_action('wpcf7_before_send_mail', 'save_form_data_to_cpt');
437+
function save_form_data_to_cpt($contact_form) {
438+
$submission = WPF7_Submission::get_instance();
439+
if ($submission) {
440+
$data = $submission->get_posted_data();
441+
442+
$post_id = wp_insert_post(array(
443+
'post_title' => $data['your-name'],
444+
'post_type' => 'supporter',
445+
'post_status' => 'draft'
446+
));
447+
update_field('name', $data['your-name'], $post_id);
448+
update_field('organization', $data['your-org'], $post_id);
449+
}
450+
}

0 commit comments

Comments
 (0)