Remove requirement for lead to have an email address.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 17 May 2019 16:55:52 +0000 (12:55 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 17 May 2019 16:55:52 +0000 (12:55 -0400)
Uptra and others need to get leads that may only have phone or
addresses.

models/admin/leads/index.php
setup/frontHooks.php
views/admin/leads/edit.html

index 9544e29..261e6e0 100644 (file)
@@ -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',
index 4a09fb9..046efa7 100644 (file)
@@ -305,11 +305,6 @@ add_action( 'gform_after_submission', function( $entry, $form ){
             }
         }
     }
-    // echo '<pre>$leads_fields: ' . print_r( $leads_fields, true ) . '</pre>';
-    // 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(
index adac773..9d9cc9a 100644 (file)
@@ -30,7 +30,7 @@
             <td colspan="2">
                 <table>
                     <tr>
-                        <td>Email</td>
+                        <th>Email</th>
                         <td>
                             {if $addingLead}
                                 <input type="text" name="email" value="">
@@ -40,7 +40,7 @@
                         </td>
                     </tr>
                     <tr>
-                        <td>Mail Ok?</td>
+                        <th>Mail Ok?</th>
                         <td>
                             {if $addingLead}
                                 <input type="checkbox" name="mail_ok" value="1">
@@ -50,7 +50,7 @@
                         </td>
                     </tr>
                     <tr>
-                        <td>Member Ok?</td>
+                        <th>Member Ok?</th>
                         <td>
                             {if $addingLead}
                                 <input type="checkbox" name="member_ok" value="1">