process_tag( $acfield['email'], $form_data,$fields,$entry_id ); $fname = $this->process_tag( $acfield['first-name'], $form_data,$fields,$entry_id); $lname = $this->process_tag( $acfield['last-name'], $form_data,$fields,$entry_id ); $phone = $this->process_tag( $acfield['phone'], $form_data,$fields,$entry_id ); $org = $this->process_tag( $acfield['organization'], $form_data,$fields,$entry_id ); //Active Campaign starts if($ac_ebable == '1' && !empty($email)){ if(!empty($AC_URL) && !empty($API_KEY) && !empty($list_ID)){ $body = array( 'email' => $email, 'first_name' => $fname, 'last_name' => $lname, 'phone' => $phone, 'orgname' => $org, 'p['.$list_ID.']' => $list_ID, 'status['.$list_ID.']' => 1, 'instantresponders['.$list_ID.']' => 0, ); //print_r($body); //die(); $args = array( 'method' => 'POST', 'timeout' => 15, 'redirection' => 15, 'headers' => "Content-Type: application/x-www-form-urlencoded", 'body' => $body, ); $api_url = $AC_URL . "/admin/api.php?api_action=contact_sync&api_output=json&api_key=".$API_KEY; $response = wp_remote_request( $api_url, $args); if( is_wp_error( $response ) ) { wpforms()->process->errors[ $form_data['id'] ]['header'] = esc_html__( 'Error in saving Data to Active Campaign', 'active-campaign-wpforms' ); } }else{ wpforms()->process->errors[ $form_data['id'] ]['header'] = esc_html__( 'You have enabled Active Campaign but have not add API Credentials and List ID.', 'active-campaign-wpforms' ); } } } public function process_tag( $string = '', $form_data, $fields, $entry_id ) { $tag = apply_filters( 'wpforms_process_smart_tags', $string, $form_data, $fields, $entry_id ); $tag = wpforms_decode_string( $tag ); $tag = sanitize_text_field( $tag ); return $tag; } } new Acwf_Subscribe(); }