function get_lead_data($fields) { include_once plugin_dir_path(__FILE__) . "form-actions.php"; $field_names = $lead_data = array(); foreach ($fields as $field) { array_push($field_names, $field["field_name"]); } $marketo_token = get_marketo_token(); $request_action = "/v1/leads.json?filterType=cookie&filterValues=" . str_replace("&", "%26", $_COOKIE["_mkto_trk"]) . "&fields=" . implode(",", $field_names); $rest_call = generate_call($request_action, $marketo_token, false); $lead_data = make_rest_call($rest_call, null, "get")->result[0]; if ($lead_data) { $lead_data = get_object_vars($lead_data); } return $lead_data; }
<?php include_once plugin_dir_path(__FILE__) . "form-actions.php"; $marketo_token = ""; $marketo_token = get_marketo_token(); $lead_update = marketo_update_lead($marketo_token); $leadId = ""; $post_reg_data = $_POST["post_reg_data"]; $post_reg_action = $_POST["post_reg_action"]; $post_reg_target = $_POST["post_reg_target"]; if ($lead_update->success) { $leadId = $lead_update->result[0]->id; marketo_assign_associate_lead($leadId, $marketo_token); $campaign_update = marketo_add_to_campaign($leadId, $marketo_token); $post_with_content = get_post($_POST['post_reg_data']); $download_file_name = $post_with_content->post_title; if ($post_reg_action == "wp_download") { //add_action( 'wp_head', 'whitepaper_post_reg' ); $whitepaper = $post_with_content->whitepaper_file; download_file($whitepaper); } else { if ($post_reg_action == 'webcast_reg') { $thank_you_page = get_permalink($post_reg_data); wp_redirect($thank_you_page); } else { if ($post_reg_action == 'webcast_presentation_download') { $presentation = $post_with_content->webcast_presentation; download_file($presentation); } else { if ($post_reg_action == 'webcast_recording_download') { $recording = $post_with_content->webcast_recording;