Page 1 of 1

First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 10:40 am
by PseudoNyhm
I have turned off First/Last name collection on my registration form. However, upon user registration, their First Name field is populated with their login username. This is not appropriate in my situation. The First Name field should be left empty.

I've confirmed that this name is, indeed, set into the database wp_usermeta first_name record upon registration. WordPress itself does not copy the username to the First Name field. Is this a behavior of s2Member?

Re: First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 12:46 pm
by Cristián Lávaque
Thanks for bringing that up.

If I remember correctly, WordPress required the name field to be populated too, so when Jason added the feature to remove the First and Last names requirement, he used the username value to populate the first name.

I just deactivated s2Member in my test installation and tried registering a new account and WordPress only asked for username and email address. They either didn't require it before either and I was under the wrong impression, or they just removed the requirement with the latest release or so.

I'll show this to Jason so he can improve the feature. Thanks!

Re: First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 1:15 pm
by PseudoNyhm
Many thanks for taking the time to test this out yourself. I look forward to the fix. Here's the background on the issue:

This is related to my research into Register Plus Redux. To prevent pending (not yet verified) accounts from being able to login, RpR populates the username with a temporary random string (username_XXXXXX). Upon verification, RpR returns the username to that selected by the user. Unfortunately, s2Member has populated the First Name with this ugly string, which sticks forever. It is then possible for other components to reference this, thinking it's a valid First Name.

Re: First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 5:00 pm
by Jason Caldwell
There are some new options in the latest release of s2Member v110708 which allow you to control the behavior of the "Display Name". Please let me know if this helps you out. You'll find these options in your Dashboard, under: s2Member -> General Options -> Custom Registration Fields. Also, I replied to a related issue about Register Plus Redux here: viewtopic.php?f=4&t=10400&p=22551#p22686

Re: First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 7:53 pm
by PseudoNyhm
Thanks for the heads-up on today's new version. I've installed it, but the First Name behavior remains.

I've configured Set "Display Name" during Registration? as No (leave Display Name at default WordPress value).

Notice that the Display Name drop-down in the admin user settings is not specifically the issue. The crux of the issue is that something is populating the First Name field with the username upon registration.

If you'd like me to test a patch, just let me know what code to edit, and I'll report how it behaves. I'm not afraid to get my hands dirty. Thanks for helping me with this.

Re: First Name field being populated (s2Member?)

PostPosted: July 8th, 2011, 9:13 pm
by Jason Caldwell
Ah, I see what you mean now.

Yes, if/when s2Member is configured NOT to require a First/Last Name, s2Member will default the First Name to the Username that is selected by the User during registration. This way other routines and Replacement Codes that reference the User's First Name and Display Name will not get just an empty string. If you'd like to test other methods of handling this, you can run a search for all instances of:
Code: Select all
eval ('$fname = trim ($login); $lname = "";'); 

Inside: /s2member/includes/classes/registrations.inc.php

Re: First Name field being populated (s2Member?)

PostPosted: July 9th, 2011, 1:11 pm
by PseudoNyhm
Thank you for the pointer. I will take a look under the hood.

In your experience, would leaving First Name blank trip up a lot of behavior? Do you know whether lots of other features expect First Name explicitly? Notice that requesting Display Name will still work, because that will return the username.

Instead of altering s2Member, is there a way for me to add something to clear the First Name field after s2Member sets it (some sort of post-registration hook)? I'm not very familiar with WordPress integration (yet), so your input would be most helpful (... before I go breaking things).

Re: First Name field being populated (s2Member?)

PostPosted: July 9th, 2011, 3:33 pm
by PseudoNyhm
Success!

As suggested, I edited /s2member/includes/classes/registrations.inc.php and commented out the three occurrences of the following block:

Code: Select all
//if (!$fname) /* Default to Username? */
//      if ($login) /* Username and empty Last Name. */
//              eval ('$fname = trim ($login); $lname = "";');
 


Upon registration, no First Name is set. The display name is correctly set in the user admin panel (to the only possible option, which is their username). This holds through the verification phase (using Register Plus Redux plugin). The user was even able to purchase a subscription via PayPal, and s2Member handled everything fine.

These edits won't survive an update, of course. As an enhancement to a future version of s2Member, may I request a General Option to choose the desired behavior (if not collecting First/Last Name)? Thanks again for your assistance.

Re: First Name field being populated (s2Member?)

PostPosted: July 9th, 2011, 4:00 pm
by Jason Caldwell
These edits won't survive an update, of course. As an enhancement to a future version of s2Member, may I request a General Option to choose the desired behavior (if not collecting First/Last Name)? Thanks again for your assistance.

Absolutely. Thanks for reporting back on this.

Re: First Name field being populated (s2Member?)

PostPosted: August 18th, 2011, 8:58 pm
by Jason Caldwell
This behavior was updated in the latest release.
If/when no names are being collected ( based on your configuration ), the First/Last Name fields remain empty, as they should be.

Re: First Name field being populated (s2Member?)

PostPosted: August 18th, 2011, 10:24 pm
by PseudoNyhm
I noticed this, and did a test registration. Worked perfect. My thanks.