× Joomla Facebook Connect support forum

Topic-icon Username for FB connect user only (User creation)

Active Subscriptions:

None
Hello,

I'd like to use the Facebook User Only option under (User Creation).
However, is there a way for it to create usernames of something other than FB82893482394 or so on? Something that incorporates the imported name instead maybe?
The component works great but this would be my only request to make it perfect.

Thanks
The topic has been locked.
Support Specialist
13 years 1 month ago #8688 by alzander
Yes, you can. We're going to add this as a configuration option in a future release, as it's starting to be requested more often. For now though, it will require a minor code change. The below should give you a starting point for doing "Alex_123456", but if you have a specific username format you'd like, let us know and we can tell you exactly how to do that. Please remember that within Joomla each username needs to be unique. That's why we use the Facebook User ID in the username, since that guarantees uniqueness.

To change, edit the /plugins/authentication/jfbconnectauth.php file. At line 108, you'll see:
$response->username = "fb_".$fbUserId;

You can update this however you want. Directly above that line full name creation, so you can see how to get the first/last names very easily.
So, if you wanted Alex_1234, the code should be:
$response->username = $fbUser."_".$fbUserId;
Or, for first-last_userid, try:
$response->username = $fbUser."-".$fbUser."_".$fbUserId;

Hope that gets you started. Again, we'll have some default configuration options in future release, but for now, the above is hopefully pretty pain-free.

Good luck, and let us know how it goes!
The topic has been locked.