Support » Fixing WordPress » Paid Memberships Pro – require email on sign-up

  • Not sure if this is something I’ve done, but users are able to register at my site without inputting their email address. How do I set email as a required field? I’d ideally like to validate the email, too. I found this code online, but I’m not sure how to hook it into the sign-up form.

    function check_email_address($email) {
      // First, we check that there's one @ symbol,
      // and that the lengths are right.
      if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
        // Email invalid because wrong number of characters
        // in one section or wrong number of @ symbols.
        return false;
      }
      // Split it into sections to make life easier
      $email_array = explode("@", $email);
      $local_array = explode(".", $email_array[0]);
      for ($i = 0; $i < sizeof($local_array); $i++) {
        if
    (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_{|}~-][A-Za-z0-9!#$%&
    ↪'*+/=?^_{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
    $local_array[$i])) {
          return false;
        }
      }
      // Check if domain is IP. If not,
      // it should be valid domain name
      if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
        $domain_array = explode(".", $email_array[1]);
        if (sizeof($domain_array) < 2) {
            return false; // Not enough parts to domain
        }
        for ($i = 0; $i < sizeof($domain_array); $i++) {
          if
    (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
    ↪([A-Za-z0-9]+))$",
    $domain_array[$i])) {
            return false;
          }
        }
      }
      return true;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The email (bemail) should be required. Are you using the pmpro_required_billing_fields hook to remove bemail from the list of fields to check?

    I don’t believe so. I put the additional fields code in my functions.php which added company and rep fields, as well as First Name and Last Name. Other than that I hadn’t messed with it in any way.

    Using that code I set bemail to be required, and it’s working fine now. I also put in a simplified version of the validation code above so it checks the format.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Paid Memberships Pro – require email on sign-up’ is closed to new replies.