Wordpress / Customization / Custom function for form submit
Custom Form Submit Function
-
STEP
Contact 7 form
function.php
function on_submit( $form, &$abort, $submission ){ if($_POST){ $postData=['name'=>$_POST['name'], 'email'=>$_POST['email'], 'mobile'=>$_POST['mobile'], 'subject'=>$_POST['subject'] , 'message'=>$_POST['message'] ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://api.jaberp.com/public/api/v1/email-notification/JOINTREPLACEMENTDELHI"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $server_output = curl_exec ($ch); print_R($server_output); echo '{"into":"#wpcf7-f13-p899-o1","status":"success","message":"Thank You! We will contact you shortly�"}'; curl_close ($ch); } exit; } add_action( 'wpcf7_before_send_mail', 'on_submit', 10, 3 ); Sticky contact form
function.php
function on_submit_ajax(){ if($_POST){ $postData=['name'=>$_POST['contact-form-name'], 'email'=>$_POST['contact-form-email'], 'mobile'=>$_POST['contact-form-phone'], 'message'=>$_POST['contact-form-message'] ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"https://api.jaberp.com/public/api/v1/email-notification/JOINTREPLACEMENTDELHI"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //Post Fields curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $server_output = curl_exec ($ch); print_R($server_output); curl_close ($ch); } } add_action('wp_ajax_nopriv_mystickyelements_contact_form', 'on_submit_ajax' ); add_action('wp_ajax_mystickyelements_contact_form', 'on_submit_ajax' );