File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -425,3 +425,28 @@ function osi_wpdc_comment_body( string $comment_body ) {
425425 return $ trimmed_comment_body ;
426426}
427427add_filter ( 'wpdc_comment_body ' , 'osi_wpdc_comment_body ' , 10 , 1 );
428+
429+ /**
430+ *
431+ * Create a new Supporter in ACF, based on a Contact Forms 7 submission.
432+ *
433+ */
434+ add_action ('wpcf7_before_send_mail ' , 'save_form_data_to_cpt ' );
435+ function save_form_data_to_cpt ($ contact_form ) {
436+ $ submission = WPCF7_Submission::get_instance ();
437+ if ($ submission ) {
438+ $ data = $ submission ->get_posted_data ();
439+
440+ $ post_id = wp_insert_post (array (
441+ 'post_title ' => $ data ['your-name ' ],
442+ 'post_type ' => 'supporter ' ,
443+ 'post_status ' => 'pending '
444+ ));
445+ update_field ('name ' , $ data ['your-name ' ], $ post_id );
446+ update_field ('organization ' , $ data ['your-org ' ], $ post_id );
447+ update_field ('endorsement_type ' , $ data ['your-endorsement ' ], $ post_id );
448+ update_field ('quote ' , $ data ['your-message ' ], $ post_id );
449+ } else {
450+ error_log ('WPCF7_Submission instance is null. ' );
451+ }
452+ }
You can’t perform that action at this time.
0 commit comments