XF 1.5 Facebook signup - real name as username

leemy

Member
Hi, I am setting up FB Connect for registration. When a username approves the FB application, the next page shows their e-mail (and profile pic, etc) are brought in, but the username field is blank.

I've searched some previous threads where there is conflicting information: real name is passed through, nothing is passed through, etc. Did this change from XF 1.1 --> XF 1.5?

I would like users who register via Facebook to have their Facebook Name as their username/display name (preferably, unchangeable from it so as to maintain their public identity on our forum).

Could you help me with that? Thanks.

upload_2016-12-1_13-30-45.webp
 
I believe this did change, though I'd say it was no later than 1.2. Realistically, the best you can potentially do is list the name by default; anything else is likely to need custom development if you want to handle a situation where two people have the same name. I don't recall if this is the value, but you may be able to access {$fbUser.name} in the template to access the name.
 
Thanks! {$fbUser.name} kept on just giving me the first name even though it said it is full name in the Facebook Graph API.

I'll put what I did here so others can learn from it (if it's right!)

I updated Facebook.php in library\xenforo\helper\ to additionally grab first_name and last_name

Code:
$client->setParameterGet('fields', 'id,name,email,birthday,gender,website,location,link,first_name,last_name');

and i updated register_facebook template. It took me a while to figure out   after trying plus signs, concat functions, and more.

Code:
<input type="text" name="username" value=
"{$fbUser.first_name} {$fbUser.last_name}"
class="textCtrl OptIn" id="ctrl_username" autofocus="true" autocomplete="off" />

I'm not a programmer so i hope this doesnt break anything. For now, the username seems to pre-populate with "firstname lastname" and allows the user to change it from that default.
 
Last edited:
You should be able to use:
Code:
value="{$fbUser.first_name} {$fbUser.last_name}"

Because you didn't have quotes, you wouldn't have been able to put spaces in the value.
 

Similar threads

Back
Top Bottom