From: Steve Sutton Date: Fri, 17 May 2019 16:55:52 +0000 (-0400) Subject: Remove requirement for lead to have an email address. X-Git-Tag: v1.2.1^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=c7706426bdc30cbbb63fb4579e1a01c97fe4841b;p=WP-Plugins%2Fglm-member-db-leads.git Remove requirement for lead to have an email address. Uptra and others need to get leads that may only have phone or addresses. --- diff --git a/models/admin/leads/index.php b/models/admin/leads/index.php index 9544e29..261e6e0 100644 --- a/models/admin/leads/index.php +++ b/models/admin/leads/index.php @@ -722,18 +722,21 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry $mail_ok = filter_var( $_REQUEST['mail_ok'], FILTER_VALIDATE_BOOLEAN ); $member_ok = filter_var( $_REQUEST['member_ok'], FILTER_VALIDATE_BOOLEAN ); if ( !$email ) { - die( 'Fatal Error: Email did not validate' ); + // die( 'Fatal Error: Email did not validate' ); + $lead = false; + } + if ( $email ) { + // Check to see if this email is already in leads table + $lead = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT * + FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads + WHERE email = %s", + $email + ), + ARRAY_A + ); } - // Check to see if this email is already in leads table - $lead = $this->wpdb->get_row( - $this->wpdb->prepare( - "SELECT * - FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads - WHERE email = %s", - $email - ), - ARRAY_A - ); if ( !$lead ) { // Insert new email address as new lead $this->wpdb->insert( @@ -1196,17 +1199,19 @@ class GlmMembersAdmin_leads_index extends GlmDataLeadEntry public function addNewLead( $email, $data, $format ) { - if ( !isset( $email ) && !$email ) { - return false; + // If no email then enter new lead and entry + if ( $email ) { + $leadId = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads + WHERE email = %s", + $email + ) + ); + } else { + $leadId = false; } - $leadId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "leads - WHERE email = %s", - $email - ) - ); if ( !$leadId ) { $this->wpdb->insert( GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'leads', diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 4a09fb9..046efa7 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -305,11 +305,6 @@ add_action( 'gform_after_submission', function( $entry, $form ){ } } } - // echo '
$leads_fields: ' . print_r( $leads_fields, true ) . '
'; - // we need to have email field - if ( !isset( $glm_leads_entry['email'] ) || !$glm_leads_entry['email'] ) { - return; - } // create the lead // check first to see if the lead exists by matching email address $lead_id = $this->wpdb->get_var( diff --git a/views/admin/leads/edit.html b/views/admin/leads/edit.html index adac773..9d9cc9a 100644 --- a/views/admin/leads/edit.html +++ b/views/admin/leads/edit.html @@ -30,7 +30,7 @@ - + - + - +
EmailEmail {if $addingLead} @@ -40,7 +40,7 @@
Mail Ok?Mail Ok? {if $addingLead} @@ -50,7 +50,7 @@
Member Ok?Member Ok? {if $addingLead}