Membership Plugin - Extra Sign-up Steps?

By gregThomas - July 8, 2013

Hi Perchpole.

I think you could achieve this fairly easily. As opposed to doing it in two stages I would add a couple of fields to the sign up form and let the user know that these will be checked against the database (perhaps the e-mail address as that should be unique, and something else only the member is likely to know). Then when you start to error check the form use the getRecords or mysql_get functions to check if a record for the user exists in your members directory, if no record exists then throw an error and don't complete the sign up process.

Let me know if you have any questions.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Perchpole - July 8, 2013

Hi, Greg -

Thanks for your advice. In this instance, what is the easiest method for "matching" between the input and existing data?

Thanks,

Perch

By gregThomas - July 8, 2013

Hi Perch,

I would use the mysql_count function to check if the user has a record in your user table, if you're using the website membership generated sign up form, something like this would work:

    if     (!@$_REQUEST['fullname'])                                                                                             { $errorsAndAlerts .= "You must enter your full name!<br/>\n"; }
    if     (!@$_REQUEST['email'])                                                                                                { $errorsAndAlerts .= "You must enter your email!<br/>\n"; }
    if     (!@$_REQUEST['first_pet'])                                                                                            { $errorsAndAlerts .= "You must enter your first pets name!<br/>\n"; }
    elseif (!isValidEmail(@$_REQUEST['email']))                                                                                  { $errorsAndAlerts .= "Please enter a valid email (example: user@example.com)<br/>\n"; }
    elseif ($emailAlreadyInUse)                                                                                                  { $errorsAndAlerts .= "That email is already in use, please choose another!<br/>\n"; }
    elseif(!mysql_count('members_table_name', "email = '".@$_REQUEST['email']."' AND first_pet = '".@$_REQUEST['first_pet']."'")){ $errorsAndAlerts .= "I'm sorry. We couldn't find you in our database."; }
    if ($useUsernames) {
      if     (!@$_REQUEST['username'])                                                                                           { $errorsAndAlerts .= "You must choose a username!<br/>\n"; }
      elseif (preg_match("/\s+/", @$_REQUEST['username']))                                                                       { $errorsAndAlerts .= "Username cannot contain spaces!<br/>\n"; }
      elseif ($usernameAlreadyInUse)                                                                                             { $errorsAndAlerts .= "That username is already in use, please choose another!<br/>\n"; }
    }
    elseif (!$useUsernames) {
      if (@$_REQUEST['username'])                                                                                                { $errorsAndAlerts .= "Usernames are not allowed!<br/>\n"; }
    }

This is just example code, so you'd need to make a few changes to get it working with your site. 

So if you had data a field that stored the users first pet and email address in fields called first_pet and email respectively, you could use the mysql_count function to check to return if a record existed for that user. You would have to add a new text field to the sign up form with a name of first_pet. If what the user had entered in the form matched what was in the first_pet and e-mail field, then 1 would be returned, otherwise 0 will be returned and an error will be triggered stating "I'm sorry. We couldn't find you in our database."

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Perchpole - July 11, 2013

Hi, Greg -

This is brilliant. It works really well. I changed the required information to firstname and lastname - in place of fullname. The system then checks to see if the combo is present in the Directory of members. If it isn't found, the sign-up form throws an error.

Perfect!

Perch

I would add a couple of fields to the sign up form.

http://www.forlingeries.com/