Code Changes
Code Changes
php
/**
* Displaying HLM Custom Form Data
*/
if (! defined('ABSPATH')) {
exit;
}
if (!class_exists('Displaying_HLM_TypeForms_Class')) {
class Displaying_HLM_TypeForms_Class
{
public function __construct(){
add_filter('manage_hlm_forms_posts_columns', array($this,
'add_hlm_forms_columnsCBF'));
add_action('manage_hlm_forms_posts_custom_column', array($this,
'add_hlm_forms_column_contentCBF'), 10, 2);
add_action('admin_menu',
array($this,'init_hlm_forms_entries_submenu_pageCBF'));
add_shortcode('hlm_typeform_wizard', array($this,
'hlm_typeform_wizard_shortcode'));
add_action('wp_enqueue_scripts', array($this,
'hlm_typeform_enqueue_scripts'));
add_action('wp_ajax_hlm_typeform_submit',
array($this,'handle_typeform_hlm_form_submission'));
add_action('wp_ajax_nopriv_hlm_typeform_submit',
array($this,'handle_typeform_hlm_form_submission'));
// Action for both filtering and exporting
add_action('admin_post_filter_or_export_records', array($this,
'handle_filter_or_export_records'));
}
function add_hlm_forms_columnsCBF($columns){
// Make a copy of the original columns array
$new_columns = array();
return $new_columns;
}
function add_hlm_forms_column_contentCBF($column, $hlm_cfposts_pid){
if ($column == 'hlm_forms_shortcode') {
echo '[hlm_typeform_wizard form_id="' . $hlm_cfposts_pid . '"]';
}
}
function init_hlm_forms_entries_submenu_pageCBF() {
add_submenu_page(
'edit.php?post_type=hlm_forms',
__('HLM Forms Entries', 'hlm-custom-mods'),
__('HLM Forms Entries', 'hlm-custom-mods'),
'manage_options',
'hlm_forms_entries',
array($this,'hlm_forms_entries_page_callback')
);
}
function hlm_forms_entries_page_callback() {
$startdate = '';
$todate = '';
$email_or_id = '';
global $wpdb;
// Get results
$results = $wpdb->get_results($query_main);
global $wpdb;
$page = isset($_GET['pagenumber']) ? intval($_GET['pagenumber']) : 1;
$per_page = 20;
$offset = ($page - 1) * $per_page;
$total_count = count($total_results);
$total_pages = ceil($total_count / $per_page);
?>
<style>
.date-filters {
margin-bottom: 20px;
}
.date-filters > label {
margin-right: 20px;
}
.hlm-form-results-table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.hlm-form-results-table th {
background-color: #0073aa;
color: white !important;
font-weight: bold;
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.csv-export-form{
display:none;
}
.records_hlmforms_pagination a {
padding: 5px 10px;
margin: 0 2px;
text-decoration: none;
border: 1px solid #ddd;
border-radius: 3px;
background-color: #f5f5f5;
}
.records_hlmforms_pagination a.active {
background-color: #0073aa;
color: white;
}
.tablenav-pages {
display: flex;
align-items: center;
margin-top: 1em;
}
.displaying-num {
margin-right: 10px;
}
.pagination-links {
display: flex;
align-items: center;
}
.pagination-links a {
margin: 0 2px;
padding: 2px 5px;
text-decoration: none;
border: 1px solid #ddd;
background-color: #f9f9f9;
color: #0073aa;
border-radius: 3px;
}
.pagination-links a.disabled {
pointer-events: none;
opacity: 0.5;
}
.paging-input {
margin: 0 5px;
display: inline-flex;
align-items: center;
}
.paging-input input {
width: 40px;
text-align: center;
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 5% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size
*/
max-width: 600px;
box-shadow: 0 5px 15px rgba(0,0,0,.5);
border-radius: 4px;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
$entry_html = '';
$entry_arr = $result->entry;
$form_id = $result->form_id;
$db_email = $result->email;
$created_at = $result->created_at;
$response = json_decode($entry_arr, true);
<span class="paging-input">
<?php echo $page; ?> of <span
class="total-pages"><?php echo $total_pages; ?></span>
</span>
</script>
<?php
// End output buffering and flush the contents for the admin page
ob_end_flush();
}
function get_input_name($question) {
$question = trim($question);
$question = strtolower($question);
$input_name = preg_replace('/[^a-z0-9]+/', '_', $question);
return $input_name;
}
function hlm_typeform_wizard_shortcode($atts){
$atts = shortcode_atts(array('form_id' => ''), $atts, 'hlm_forms');
$form_id = $atts['form_id'];
ob_start();
global $post;
$post_id = $post->ID;
$form_id = $form_id ? $form_id : $post_id;
$form_redirect_url = get_field('redirect_url', $form_id);
$counter = 1;
if (have_rows('questionnaire', $form_id)) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>
<?php echo get_the_title($form_id); ?>
</title>
</head>
<style>
body {
padding-bottom: 50px;
background: #EEEDEC;
}
/***additional_changes***/
.single-post .for-wizard-outer-container {
padding:0px;
}
.single-post label.hlm-typeform-question{
font-size:26px;
margin-bottom: 10px;
}
.single-post input#hlm-typeform-text {
font-size:22px;
}
.single-post .hlm-typeform-email-field{
font-size: 22px;
}
.single-post span.sign-sect{
margin-bottom: 0px;
margin-top: 25px;
font-size: 22px;
}
a.form-anchor-link {
font-size: 22px;
font-weight: 600;
text-decoration: underline;
}
.single-post .hlm-typeform-left-column {
padding: 25px 15px 25px 40px;
}
.single-post .form-radio-outer-sect, .single-post .form-
checkbox-outer-sect{
flex-wrap: nowrap;
font-size: 22px;
}
textarea{
font-size:22px;
}
.single-post .hlm-typeform-nextBtns, .single-post .hlm-
typeform-nextBtns:hover, .single-post .hlm-typeform-nextBtns:focus, .single-
post .hlm-typeform-nextBtns:active, .single-post .hlm-typeform-
nextBtns:visited, .single-post .hlm-typeform-nextBtns:link{
font-size: 24px;
font-weight: 600;
line-height: 100%;
margin: 25px 0 0;
width: 140.878px;
height: 50.437px;
}
.single-post span.required-text-sect {
font-size:18px;
}
.single-post .hlm-typeform-form-container {
min-height:700px
}
.single-post .form-radio-outer-sect, .form-checkbox-outer-sect{
font-size:26px;
}
/***additional_changes***/
.page-template-hlm-typeform .wpb-content-wrapper{
max-width: 100% !important;
}
.hlm-typeform-email-field{
display: block;
width: 100%;
font-family: inherit;
color: rgb(1, 66, 172);
/* padding-top: 35px !important; */
padding-bottom: var(--spacing-100);
border: none !important;
outline: none;
background-color: transparent !important;
font-size: 30px;
line-height: 30px;
-webkit-text-fill-color: rgb(1, 66, 172);
transition: box-shadow 0.1s ease-out;
box-shadow: rgba(1, 66, 172, 0.3) 0px 1px;
padding: 7px;
}
.hlm-typeform-text-field{
display: block;
width: 100%;
font-family: inherit;
color: rgb(1, 66, 172);
/* padding-top: 35px !important; */
padding-bottom: var(--spacing-100);
border: none !important;
outline: none;
background-color: transparent !important;
font-size: 30px;
line-height: 30px;
-webkit-text-fill-color: rgb(1, 66, 172);
transition: box-shadow 0.1s ease-out;
box-shadow: rgba(1, 66, 172, 0.3) 0px 1px;
}
.form-radio-outer-sect, .form-checkbox-outer-sect {
border-radius: 40px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-start;
background: #E3ECF6;
padding: 7px;
width: 85%;
margin-bottom: 15px;
font-style: normal;
font-weight: 400;
font-size: 28px;
line-height: 135%;
color: #0E5FBA;
position:relative;
}
span.form-circle-sect {
width: 40px;
height: 40px;
border-radius: 50px;
background: #FFFFFF;
margin-right: 10px;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
color: #0E5FBA;
}
.form-checkbox-outer-sect span.form-circle-sect{
color:#FFFFFF;
}
.hlm-typeform-left-column .form-checkbox-outer-sect .active-
check-sign {
color: #0E5FBA !important;
}
.hlm-typeform-left-column input[type="radio"], .hlm-typeform-
left-column input[type="checkbox"] {
width: 100%;
height: 100%;
position: absolute;
z-index: 9999999;
opacity: 0;
}
.active-answer-sect {
background: #0E5FBA;
color: #FFFFFF;
}
span.required-text-sect {
font-weight: 400;
font-size: 24px;
line-height: 135%;
color: #838383;
}
label.hlm-typeform-question {
font-weight: 750;
font-size: 38px;
line-height: 130%;
color: #000000;
margin-bottom: 40px;
width:100%;
}
span.sign-sect {
font-weight: 400;
font-size: 28px;
line-height: 135%;
letter-spacing: -0.01em;
color: #000000;
margin-bottom: 25px;
}
.for-wizard-outer-container {
padding: 35px 100px;
/* background: #EEEDEC; */
}
.form-logo-sect {
text-align: center;
margin-bottom: 35px;
}
.form-logo-sect img {
width: 250px;
object-fit: cover;
}
textarea {
background: #FFFFFF;
border: 1px solid #C1C1C1;
border-radius: 16px;
padding: 10px;
width: 100%;
font-size: 24px;
}
textarea::placeholder {
font-weight: 400;
font-size: 24px;
line-height: 135%;
/* or 38px */
color: #BABABA;
}
.hlm-typeform-right-column img{
display:none;
}
/* Basic styling */
body {
font-family: Arial, sans-serif;
padding: 20px;
background-color: #f5f5f5;
}
.hlm-typeform-wizard {
background-color: #FFFFFF;
border-radius: 40px;
margin: auto;
box-shadow: 0px 4px 25.7px rgba(156, 155, 151, 0.25);
overflow: hidden;
position:relative;
.hlm-typeform-progress-bar {
height: 10px;
background-color: #d92d27;
width: 0%;
}
.hlm-typeform-step {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 100%;
transition: all 0.5s ease;
opacity: 0;
display: flex;
}
.hlm-typeform-step.hlm-typeform-active {
left: 0;
opacity: 1;
}
.hlm-typeform-step.hlm-typeform-previous {
left: -100%;
}
.hlm-typeform-left-column {
width: 50%;
padding: 50px 30px 50px 80px;
display: flex;
align-items: center;
flex-wrap: wrap;
align-content: center;
/* margin-bottom: 150px; */
}
.hlm-typeform-right-column {
width: 50%;
display: flex;
justify-content: center;
align-items: center;
position:relative;
}
.hlm-typeform-right-column img {
max-width: 100%;
height: auto;
border-radius: 10px;
}
.hlm-typeform-btn {
background-color: transparent;
color: #da291c;
padding: 0px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 40px;
font-weight: bold;
margin-right: 20px;
}
.hlm-typeform-btn[disabled] {
cursor: not-allowed;
opacity: 0.7;
}
.hlm-typeform-btn:hover, .hlm-typeform-btn:focus{
background-color: transparent;
color: #da291c;
}
.hlm-typeform-step-number {
margin-bottom: 10px;
font-weight: bold;
}
.hlm-typeform-error-message {
margin-top: 15px;
color: red;
font-size: 0.9em;
display: none;
margin-bottom: 20px;
}
input.hlm-typeform-error,
textarea.hlm-typeform-error {
border: 1px solid red;
}
#hlm-typeform-mobile-navigation {
width: 90%;
display: none;
justify-content: center;
align-items: center;
position: absolute;
bottom: 75px; /* 90px */
padding: 0 20px;
}
#hlm-typeform-loader-overlay {
display: flex;
justify-content: center;
align-items: center;
background-color: #000000;
opacity: 0.75;
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 999999;
color: #ffffff;
flex-direction: column;
font-size: 20px;
}
.hlm-typeform-loader-spinner {
width: 70px;
aspect-ratio: 1;
border-radius: 50%;
border: 8px solid #ffffff;
animation: l20-1 0.8s infinite linear alternate, l20-2 1.6s
infinite linear;
}
@keyframes l20-1{
0% {clip-path: polygon(50% 50%,0 0, 50% 0%, 50%
0%, 50% 0%, 50% 0%, 50% 0% )}
12.5% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100%
0%, 100% 0%, 100% 0%, 100% 0% )}
25% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100%
0%, 100% 100%, 100% 100%, 100% 100% )}
50% {clip-path: polygon(50% 50%,0 0, 50% 0%, 100%
0%, 100% 100%, 50% 100%, 0% 100% )}
62.5% {clip-path: polygon(50% 50%,100% 0, 100% 0%, 100%
0%, 100% 100%, 50% 100%, 0% 100% )}
75% {clip-path: polygon(50% 50%,100% 100%, 100% 100%, 100%
100%, 100% 100%, 50% 100%, 0% 100% )}
100% {clip-path: polygon(50% 50%,50% 100%, 50% 100%, 50%
100%, 50% 100%, 50% 100%, 0% 100% )}
}
@keyframes l20-2{
0% {transform:scaleY(1) rotate(0deg)}
49.99%{transform:scaleY(1) rotate(135deg)}
50% {transform:scaleY(-1) rotate(0deg)}
100% {transform:scaleY(-1) rotate(-135deg)}
}
</style>
<main>
<!-- Loader Overlay -->
<div id="hlm-typeform-loader-overlay" style="display: none;">
<div class="hlm-typeform-loader-spinner"></div>
<p>Please Wait...</p>
</div>
<!-- Form Wizard HTML -->
<div class="for-wizard-outer-container">
<div class="form-logo-sect">
<a href="/"><img decoding="async"
src="https://iheartdogs.com/wp-content/uploads/2023/08/iHeartDogsLogo-300px.png"
alt="iHeartDogs.com" class="wp-image-2706741"></a>
</div>
<div class="hlm-typeform-wizard">
<form method="post" class="hlm-typeform-form" id="hlm-
typeform-form" name="hlm-typeform-form" style="margin-block-end: 0;">
<?php wp_nonce_field('hlm_forms_quest_ans_nonceaction',
'hlm_forms_quest_ans_noncefield'); ?>
<input type="hidden" name="form_id_inputfield"
value="<?php echo esc_attr($form_id); ?>" />
<input type="hidden" name="form_id_redirect_url"
id="form_id_redirect_url" value="<?php echo esc_attr($form_redirect_url); ?>" />
<div class="hlm-typeform-form-container">
<?php
$letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z'];
while (have_rows('questionnaire', $form_id ?
$form_id : $post_id)): the_row();
$index = 0;
$question_text = get_sub_field('question');
$image_url = get_sub_field('image');
$information_box =
strtolower(get_sub_field('information_box'));
?>
<div class="hlm-typeform-step <?php echo
get_row_index() == 1 ? 'hlm-typeform-active' : ''; ?>">
<div class="hlm-typeform-left-column" <?php
if(!$image_url){ ?> style="width:75%;margin:0 auto;padding: 0px;min-height:100vh"<?
php } ?>>
<?php if($information_box == 'no'){ ?>
<span class="required-text-sect">This
question is required.*</span>
<?php } ?>
<label class="hlm-typeform-question"><?
php echo esc_html($question_text); ?></label>
<?php if($information_box == 'no'){ ?>
<?php while (have_rows('options')):
the_row();
$label_text =
get_sub_field('label');
$option_type =
strtolower(get_sub_field('option_type'));
if ($option_type == 'email') { ?>
<span class="sign-sect">👇<?=
$label_text ?></span>
<input type="email" id="hlm-
typeform-email" class="hlm-typeform-email-field" style="margin-top: 12px;" name="<?
= $this->get_input_name($question_text) ?>" placeholder="[email protected]">
<?php } elseif ($option_type ==
'textarea') { ?>
<textarea id="hlm-typeform-
summary" class="form-control" style="margin-top: 12px;" rows="8" placeholder="<?=
$label_text ?>" name="<?= $this->get_input_name($question_text) ?>"></textarea>
<?php } elseif ($option_type ==
'radio') { ?>
<div class="form-radio-outer-
sect">
<input type="radio"
id="hlm-typeform-male" style="margin-top: 12px;" name="<?= $this-
>get_input_name($question_text) ?>" value="<?php echo $label_text; ?>">
<?php if
(isset($letters[$index])) {
echo '<span
class="form-circle-sect">' . $letters[$index] . '</span>';
$index++;
} ?>
<span class="form-radio-
label"><?php echo $label_text; ?></span>
</div>
<?php } elseif ($option_type ==
'checkbox') { ?>
<div class="form-checkbox-
outer-sect">
<input type="checkbox"
id="hlm-typeform-option1" style="margin-top: 12px;" name="<?= $this-
>get_input_name($question_text) ?>[]" value="<?php echo $label_text; ?>">
<span class="form-circle-
sect">✔</span>
<span class="form-checkbox-
label"><?php echo $label_text; ?></span>
</div>
<?php } elseif ($option_type ==
'text') { ?>
<input type="text" id="hlm-
typeform-text" class="hlm-typeform-text-field" style="margin-top: 12px;" name="<?=
$this->get_input_name($question_text) ?>" placeholder="<?= $label_text; ?>">
<?php } elseif ($option_type ==
'url'){
$url = get_sub_field('url');?>
<a href="<?php echo $url; ?>"
target="_blank" class="form-anchor-link"><?php echo $label_text; ?></a>
<?php }
endwhile; ?>
<?php } ?>
<div class="hlm-typeform-error-message"
id="hlm-typeform-errors">Sorry! Answer to this question is required.</div>
</div>
<?php endwhile; ?>
</div>
<!-- Navigation Buttons -->
<div style="position:absolute; bottom: 15px;
left:36px;" id="hlm-typeform-desktop-navigation">
<button class="hlm-typeform-btn hlm-typeform-
prevBtn" id="hlm-typeform-prevBtn" disabled>
<!-- ⟨ -->
<svg xmlns="http://www.w3.org/2000/svg"
width="20" height="33" viewBox="0 0 20 33" fill="none">
<path d="M20 28.5502L7.63318 16.1834L20
3.81659L16.1834 0L0 16.1834L16.1834 32.3668L20 28.5502Z" fill="currentColor"/>
</svg>
</button>
<button class="hlm-typeform-btn hlm-typeform-
nextBtn" id="hlm-typeform-nextBtn">
<!-- ⟩ -->
<svg xmlns="http://www.w3.org/2000/svg"
width="20" height="33" viewBox="0 0 20 33" fill="none">
<path opacity="1" d="M0 28.5502L12.3668
16.1834L0 3.81659L3.81659 0L20 16.1834L3.81659 32.3668L0 28.5502Z"
fill="currentColor"/>
</svg>
</button>
</div>
<div id="hlm-typeform-mobile-navigation">
<button class="hlm-typeform-btn hlm-typeform-
prevBtn" id="hlm-typeform-prevBtn" disabled>
<!-- ⟨ -->
<svg xmlns="http://www.w3.org/2000/svg"
width="20" height="33" viewBox="0 0 20 33" fill="none">
<path d="M20 28.5502L7.63318 16.1834L20
3.81659L16.1834 0L0 16.1834L16.1834 32.3668L20 28.5502Z" fill="currentColor"/>
</svg>
</button>
<button class="hlm-typeform-btn hlm-typeform-
nextBtns" style="width: inherit;" id="hlm-typeform-mobile-nextBtn">Next</button>
<button type="submit" class="hlm-typeform-btn hlm-
typeform-nextBtns" style="width: inherit; display: none;" id="hlm-typeform-mobile-
submitBtn">Submit</button>
</div>
</form>
</div>
</div>
<!-- Progress Bar at the Bottom -->
<div class="hlm-typeform-progress-bar-wrapper">
<div class="hlm-typeform-progress-bar" id="hlm-typeform-
progressBar"></div>
</div>
</main>
<?php } // End if (have_rows('questionnaire'))
?>
<script>
jQuery(document).ready(function($) {
jQuery('.hlm-typeform-right-column').each(function(index) {
var imgSrc = $(this).find('img').attr('src');
var className = 'hlm-typeform-right-column-' + index;
if (n === -1){
jQuery('.form-radio-outer-sect').removeClass('active-
answer-sect');
}
$(steps[currentStep]).removeClass('hlm-typeform-
active').addClass(n === 1 ? 'hlm-typeform-previous' : 'hlm-typeform-next');
currentStep += n;
setTimeout(() => {
$(steps[currentStep]).removeClass('hlm-typeform-
previous hlm-typeform-next').addClass('hlm-typeform-active');
}, 10);
hlmTypeformUpdateProgressBar();
if (currentStep === 0) {
$('.hlm-typeform-prevBtn').attr('disabled', true);
} else {
$('.hlm-typeform-prevBtn').attr('disabled', false);
}
inputs.each(function() {
const input = $(this);
const errorDiv = jQuery('.hlm-typeform-error-message');
input.removeClass('hlm-typeform-error');
errorDiv.hide();
return valid;
}
$('.hlm-typeform-nextBtn').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
hlmTypeformNextPrev(1);
});
jQuery('input[type=radio]').change(function(){
if (currentStep < steps.length - 1) {
// Trigger the next button if it's not the last step
jQuery('#hlm-typeform-nextBtn2').trigger('click');
}
// jQuery('#hlm-typeform-nextBtn2').trigger('click');
})
jQuery('.hlm-typeform-nextBtns').on('click', function(e) {
if((jQuery(this).attr('id') === 'hlm-typeform-submitBtn')
|| (jQuery(this).attr('id') === 'hlm-typeform-mobile-submitBtn')){
e.preventDefault();
e.stopPropagation();
// if (!hlmTypeformValidateForm(currentInputs)) return;
jQuery('#hlm-typeform-loader-overlay').show();
var form_id_redirect_url =
jQuery('#form_id_redirect_url').val();
var ajaxurl = '<?php echo admin_url('admin-
ajax.php'); ?>';
jQuery.ajax({
url: ajaxurl,
method: 'POST',
data: {
action: 'hlm_typeform_submit',
form_data: formData,
_ajax_nonce:
jQuery('#hlm_forms_quest_ans_noncefield').val()
},
success: function(response) {
// form[0].reset();
window.location.href = (form_id_redirect_url);
},
complete: function() {
// form[0].reset();
// currentStep = 0;
// hlmTypeformResetForm();
},
error: function() {
alert('There was an error submitting the form.
Please try again.');
console.log('There was an error submitting the
form. Please try again.');
},
});
}else{
e.preventDefault();
e.stopPropagation();
hlmTypeformNextPrev(1);
}
});
});
</script>
<style>
.hlm-typeform-nextBtns,
.hlm-typeform-nextBtns:hover,
.hlm-typeform-nextBtns:focus,
.hlm-typeform-nextBtns:active,
.hlm-typeform-nextBtns:visited,
.hlm-typeform-nextBtns:link {
margin: 50px 0 0;
width: 204.878px;
height: 58.437px;
flex-shrink: 0;
border-radius: 39.971px;
background: var(--iHeartDogs-Red, #E22726);
color: var(--iHeartDogs-White, #FFF);
text-align: center;
font-size: 28px;
font-style: normal;
font-weight: 750;
line-height: 135%;
}
</style>
</html>
<?php
return ob_get_clean();
}
// Enqueue jQuery and the custom script for the form wizard
function hlm_typeform_enqueue_scripts() {
// Enqueue jQuery (default in WordPress)
wp_enqueue_script('jquery');
if (!isset($_POST['form_data'])) {
wp_send_json_error('No form data received');
}
parse_str($_POST['form_data'], $form_data);
// Validate form ID and email
if (empty($form_data['form_id_inputfield'])) {
wp_send_json_error('Form ID is missing');
}
if (empty($form_data['email_field']) || !
filter_var($form_data['email_field'], FILTER_VALIDATE_EMAIL)) {
wp_send_json_error('Invalid or missing email');
}
$form_id = sanitize_text_field($form_data['form_id_inputfield']);
$email = sanitize_email($form_data['email_field']);
$json_data = json_encode($sanitized_data);
if ($form_id) {
global $wpdb;
$table_name = "hlm_forms";
function handle_filter_or_export_records() {
// Check nonce for security
if (!isset($_POST['records_hlmforms_noncefield']) || !
wp_verify_nonce($_POST['records_hlmforms_noncefield'],
'records_hlmforms_nonceaction')) {
die('Invalid nonce');
}
global $wpdb;
// Complete the query with ordering (no pagination here for export)
$query_main .= " ORDER BY hlm_forms.id DESC";
$requestPayload = json_encode([
'data' => [
'type' => 'profile-subscription-bulk-create-job',
'attributes' => [
'custom_source' => 'Marketing Event',
'profiles' => [
'data' => [
[
'type' => 'profile',
'attributes' => [
'email' => $email,
'subscriptions' => [
'email' => [
'marketing' => [
'consent' => 'SUBSCRIBED'
]
]
]
]
]
]
]
],
'relationships' => [
'list' => [
'data' => [
'type' => 'list',
'id' => $listID
]
]
]
]
]);
$contact_data = array(
'contacts' => array(
array(
'email' => $email,
'email_consent' => true,
),
),
);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $endPoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($contact_data),
CURLOPT_HTTPHEADER => $headers,
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$status = 'Failed';
return $status;
}
} // class
$Displaying_HLM_TypeForms_Class = new Displaying_HLM_TypeForms_Class();
} // if class