full name membership signup

By rez - January 23, 2014 - edited: January 23, 2014

I have website membership, facebook login and twitter login. 

Isn't it standard to make first name and last name separate? It seem like you could sort people better, address them by first name in emails, etc.

I havent used any of these plugins or setup any type of online memberships before. Before i get into making that change to your included examples, is there anything I should know about integration or cons of separating my members names into first name and last name for website membership?

Pros and cons?

thanks.

By gregThomas - January 23, 2014

Hi Rez,

We mainly use a single name field as opposed to first and last name because CMS Builder's admin section already has a field with that name by default, and for simplicity. I agree that breaking up the field into first name/last name has several advantages.

I've done some local testing, and deleting the fullname field and replacing it with a first name/last name field doesn't create any issues. You'll just have to update your sign up page and update profile page to use the first name/last name fields instead of the full name field, otherwise there shouldn't be any issues.

Let me know if you have any questions, or would like a hand updating the code for the signup and profile pages.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - January 27, 2014

Hi Rez,

To store the first and last name of a user via Facebook, you need to edit line 250 of facebookLogin.php in your plugins directory. You need to update it to look like this:

  // adding available information to the new user record
  // a list of available fields can be found here http://developers.facebook.com/docs/reference/login/basic-info/
  $columnsToValues['email']    = $user['email'];
  $columnsToValues['username'] = $user['email'];
  if (array_key_exists( 'fullname', $schema )) {
    $columnsToValues['fullname'] = $user['name'];
  }

  $columnsToValues['first_name'] => $user['first_name'];
  $columnsToValues['last_name']  => $user['last_name'];

I've highlighted the new content I've added in green. The $columnsToValues are the field names for the members table. $user is an array of values returned by the facebook plugin (in this examle they just happen to have the same keys as our local fields).


So $columnsToValues is the data that will be saved against the users account when an account is created for them.


Here is a list of all of the keys returned in the facebook array:  id, name, first_name, last_name ,link, hometown, location, bio, quotes, work,  education,  gender,  email,  timezone,  locale,  verified, updated_time, username.


It would be possible to store this data from facebook against a user as well.


Unfortunately, the twitter login system gives us a lot less information than the facebook version. It does return a users screen name, but it won't return the users e-mail address or full name. So when a user registers via the twitter plugin for the first time, we ask them to fill out a form that contains the required information for us. This form is the twitter connect form, and is generated via the CMS Builder Code Generator. You'd just need to add two new fields to the form for the users first and last name and ensure the data is saved, much like the user registration form.


Thanks!


Greg

Greg Thomas







PHP Programmer - interactivetools.com