__( 'Autopilot', 'advanced-form-integration' ), 'tasks' => array( 'subscribe' => __( 'Add/Update Contact', 'advanced-form-integration' ), ) ); return $actions; } add_filter( 'adfoin_settings_tabs', 'adfoin_autopilot_settings_tab', 10, 1 ); function adfoin_autopilot_settings_tab( $providers ) { $providers['autopilot'] = __( 'Autopilot', 'advanced-form-integration' ); return $providers; } add_action( 'adfoin_settings_view', 'adfoin_autopilot_settings_view', 10, 1 ); function adfoin_autopilot_settings_view( $current_tab ) { if( $current_tab != 'autopilot' ) { return; } $nonce = wp_create_nonce( "adfoin_autopilot_settings" ); $api_key = get_option( 'adfoin_autopilot_api_key' ) ? get_option( 'adfoin_autopilot_api_key' ) : ""; ?>

Autopilot API to get the API Key', 'advanced-form-integration' ); ?>

30, 'headers' => array( 'Content-Type' => 'application/json', 'autopilotapikey' => $api_key ) ); $data = wp_remote_request( $url, $args ); if( is_wp_error( $data ) ) { wp_send_json_error(); } $body = json_decode( $data["body"] ); $lists = wp_list_pluck( $body->lists, 'title', 'list_id' ); wp_send_json_success( $lists ); } add_action( 'adfoin_autopilot_job_queue', 'adfoin_autopilot_job_queue', 10, 1 ); function adfoin_autopilot_job_queue( $data ) { adfoin_autopilot_send_data( $data['record'], $data['posted_data'] ); } /* * Handles sending data to Autopilot Journeys API */ function adfoin_autopilot_send_data( $record, $posted_data ) { $api_key = get_option( 'adfoin_autopilot_api_key' ) ? get_option( 'adfoin_autopilot_api_key' ) : ""; if(!$api_key ) { return; } $record_data = json_decode( $record["data"], true ); if ( adfoin_check_conditional_logic( $record_data['action_data']['cl'] ?? array(), $posted_data ) ) { return; } $data = $record_data["field_data"]; $task = $record["task"]; if( $task == "subscribe" ) { $sequence_id = $data["listId"]; $email = empty( $data["email"] ) ? "" : adfoin_get_parsed_values( $data["email"], $posted_data ); $first_name = empty( $data["firstName"] ) ? "" : adfoin_get_parsed_values( $data["firstName"], $posted_data ); $last_name = empty( $data["lastName"] ) ? "" : adfoin_get_parsed_values( $data["lastName"], $posted_data ); $twitter = empty( $data["twitter"] ) ? "" : adfoin_get_parsed_values( $data["twitter"], $posted_data ); $salutation = empty( $data["salutation"] ) ? "" : adfoin_get_parsed_values( $data["salutation"], $posted_data ); $company = empty( $data["company"] ) ? "" : adfoin_get_parsed_values( $data["company"], $posted_data ); $numberofemployees = empty( $data["numberOfEmployees"] ) ? "" : adfoin_get_parsed_values( $data["numberOfEmployees"], $posted_data ); $title = empty( $data["title"] ) ? "" : adfoin_get_parsed_values( $data["title"], $posted_data ); $industry = empty( $data["industry"] ) ? "" : adfoin_get_parsed_values( $data["industry"], $posted_data ); $phone = empty( $data["phone"] ) ? "" : adfoin_get_parsed_values( $data["phone"], $posted_data ); $mobilephone = empty( $data["mobilePhone"] ) ? "" : adfoin_get_parsed_values( $data["mobilePhone"], $posted_data ); $fax = empty( $data["fax"] ) ? "" : adfoin_get_parsed_values( $data["fax"], $posted_data ); $website = empty( $data["website"] ) ? "" : adfoin_get_parsed_values( $data["website"], $posted_data ); $mailingstreet = empty( $data["mailingStreet"] ) ? "" : adfoin_get_parsed_values( $data["mailingStreet"], $posted_data ); $mailingcity = empty( $data["mailingCity"] ) ? "" : adfoin_get_parsed_values( $data["mailingCity"], $posted_data ); $mailingstate = empty( $data["mailingState"] ) ? "" : adfoin_get_parsed_values( $data["mailingState"], $posted_data ); $mailingpostalcode = empty( $data["mailingPostalCode"] ) ? "" : adfoin_get_parsed_values( $data["mailingPostalCode"], $posted_data ); $mailingcountry = empty( $data["mailingCountry"] ) ? "" : adfoin_get_parsed_values( $data["mailingCountry"], $posted_data ); $leadsource = empty( $data["leadSource"] ) ? "" : adfoin_get_parsed_values( $data["leadSource"], $posted_data ); $status = empty( $data["status"] ) ? "" : adfoin_get_parsed_values( $data["status"], $posted_data ); $linkedin = empty( $data["linkedIn"] ) ? "" : adfoin_get_parsed_values( $data["linkedIn"], $posted_data ); $notify = empty( $data["notify"] ) ? "" : adfoin_get_parsed_values( $data["notify"], $posted_data ); $url = "https://api2.autopilothq.com/v1/contact"; $data = array( "contact" => array( "Email" => $email, "FirstName" => $first_name, "LastName" => $last_name, "Twitter" => $twitter, "Salutation" => $salutation, "Company" => $company, "NumberOfEmployees" => $numberofemployees, "Title" => $title, "Industry" => $industry, "Phone" => $phone, "MobilePhone" => $mobilephone, "Fax" => $fax, "Website" => $website, "MailingStreet" => $mailingstreet, "MailingCity" => $mailingcity, "MailingState" => $mailingstate, "MailingPostalCode" => $mailingpostalcode, "MailingCountry" => $mailingcountry, "LeadSource" => $leadsource, "LinkedIn" => $linkedin, ) ); $data = array_filter( $data ); if( $sequence_id ) { $data["contact"]["_autopilot_list"] = $sequence_id; } $args = array( 'timeout' => 30, 'headers' => array( 'Content-Type' => 'application/json', 'autopilotapikey' => $api_key ), 'body' => wp_json_encode( $data ) ); $return = wp_remote_post( $url, $args ); adfoin_add_to_log( $return, $url, $args, $record ); } return; }