Work on the become a member form.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 17 Apr 2018 20:37:34 +0000 (16:37 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 17 Apr 2018 20:37:34 +0000 (16:37 -0400)
Setting up checks for wpUser by email. give error message.
check password match and contain proper length.

models/front/billing/becomeMember.php
views/front/billing/becomeMember.html

index 705866d..7ebb33c 100644 (file)
@@ -121,11 +121,31 @@ class GlmMembersFront_billing_becomeMember // extends GlmDataBilling
             $messages[] = '<pre>$email_to_check: ' . print_r( $email_to_check, true ) . '</pre>';
             $verify_email   = filter_var( $_REQUEST['email_verify'], FILTER_VALIDATE_EMAIL );
             $messages[] = '<pre>$verify_email: ' . print_r( $verify_email, true ) . '</pre>';
-            if ( $email_to_check !== $verify_email ) {
+            if ( !$email_to_check ) {
+                $error = true;
+                $messages[] = $errors['email'] = "<span style='color: red;'>Not a valid Email!</span>";
+            }
+            if ( $email_to_check != $verify_email ) {
                 // Emails don't match give error message
                 $error = true;
                 $messages[] = $errors['email'] = "<span style='color: red;'>Emails don't match!</span>";
             }
+            // Check for wordpress user with same email address
+            $wpUser = get_user_by( 'email', $email_to_check );
+            if ( is_object( $wpUser ) && $wpUser->ID ) {
+                $error = true;
+                $messages[] = $errors['email'] = "<span style='color: red;'>There's a user with that email already!</span>";
+            }
+            $passwd         = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING );
+            $confirm_passwd = filter_var( $_REQUEST['confirm_password'], FILTER_SANITIZE_STRING );
+            if ( $passwd != $confirm_passwd ) {
+                $error = true;
+                $messages[] = $errors['password'] = "<span style='color: red;'>Passwords don't match!</span>";
+            }
+            // if ( isset( $passwd ) && preg_match()
+            // $messages[] = '<pre>$wpUser: ' . print_r( $wpUser, true ) . '</pre>';
+            // Password test.
+            // Verify they match and they aren't weak passwords.
 
             // Process the main form
 
index ebe1fd0..85fc4b9 100644 (file)
@@ -79,7 +79,6 @@
                 name="email"
                 {if isset($smarty.request.email) && $smarty.request.email}value="{$smarty.request.email}"{/if}
                 required />
-                {if $errors.email}{$errors.email}{/if}
             </div>
         </div>
         <div class="glm-billing-field glm-billing-right-half">
@@ -94,6 +93,7 @@
                 required />
             </div>
         </div>
+        {if $errors.email}<div>{$errors.email}</div>{/if}
         {* START - Custom Fields part for MiGCSA *}
         <div class="glm-billing-field">
             <div class="glm-billing-label">
                 required />
             </div>
         </div>
+        <div>
+            The password must be at least 8 characters and include at least one number, one letter, and at least one special character. (# . - _ , $ % & !)
+        </div>
         <div class="glm-billing-field glm-billing-left-half">
             <div class="glm-billing-label glm-required">
                 Password
             </div>
             <div class="glm-billing-input">
                 <input
-                type="text"
+                type="password"
                 name="password"
+                {literal}pattern="(?=.*\d)(?=.*[a-z]).{6,}"{/literal}
                 {if isset($smarty.request.password) && $smarty.request.password}value="{$smarty.request.password}"{/if}
                 required />
             </div>
             </div>
             <div class="glm-billing-input">
                 <input
-                type="text"
+                type="password"
                 name="confirm_password"
+                {literal}pattern="(?=.*\d)(?=.*[a-z]).{6,}"{/literal}
                 {if isset($smarty.request.confirm_password) && $smarty.request.confirm_password}value="{$smarty.request.confirm_password}"{/if}
                 required />
             </div>
         </div>
+        {if $errors.password}<div>{$errors.password}</div>{/if}
 
     </fieldset>