Most sites that use Facebook Connect as a login method don't require that users input account information specifically for that site. For usability reasons, it would be great if the fbconnect module let people create a functioning account without asking for a separate Drupal username and password. Here's some rough code to do this:

function fbconnect_register_page() {
  global $user;
 if (($fbuid = fbconnect_get_fbuid()) && !$user->uid) {   
   switch (arg(2)) {
     case 'import':
     case 'create':
	$fbuid = fbconnect_get_fbuid();
 	$name = fbconnect_get_fbname($fbuid);
	$fb_return = facebook_client()->api_client->users_getInfo($fbuid, array('proxied_email')); // (http://wiki.developers.facebook.com/index.php/Proxied_Email)
	$mail = $fb_return[0]['proxied_email'];
$user_default = array('name' => $name, // function gets this from Facebook
							'pass' => user_password(),
							'init' => $mail, // init is email address
							'status' => 1,
							'mail' => $mail, // function gets this from Faceboo  
							);
		$user_default['roles'][DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
		$account = user_save('', $user_default);
		watchdog('fbconnect', t('New user: %name %email.', array('%name' => $name, '%email' => '<'. $mail .'>')), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
		$user = user_load(array('name' => fbconnect_get_fbname($fbuid)));
		fbconnect_register($user->uid, $fbuid);
		$output .= "Registration complete.";
		return $output; 
   }    
   return $output;
 }
}

Note that in order for the mail (& init) fields to get saved correctly the users table would have to be modified so those fields are varchar(255) or something close to that. Unfortunately, Facebook's proxied emails are extremely long strings. If anyone knows of a way to get the user's real email address (such as taking it from the Login to Facebook popup window), that would be much better.

Also, this code seems to perform poorly & doesn't do any validation to make sure that there isn't already a user with this info. Suggestions for improvement would be greatly appreciated.

Comments

ericatkins’s picture

I agree. I have a feeling that this is how most people are wanting this module to work.

Major blogs that are implementing Facebook Connect, Gawker properties or TechCrunch.com, want users to comment; not create accounts in their website. I also want the same.

I want Facebook users that find my blog to be able to post a comment without having to register at my website. I just want their profile picture, their name, and their comment.

I think TechCrunch has implemented Facebook Connect very well. I would like that same kind of integration on my website and I think this module if very close to doing just that.

EvanDonovan’s picture

Using Facebook Connect for comments would be good. Unfortunately, I don't know if it's possible for Drupal to support people commenting with a profile picture and a username without creating a user account for them. If you have the chance, maybe you could test out my code for creating user accounts based on Facebook info? (On a test site, of course - it's very preliminary.)

stevebayerin’s picture

Having FBConnect pull in at least the name of the commenter for site comments would be extremely useful.

I'm not sure if FB policies would allow the email address and user picture being auto filled in case the commenter wishes to 'upgrade' their site role to an authenticated user but it sure would be useful to have the user e-mail and user picture (and possibly a FB profile link in the member profile) being auto filled when registering as a site member after connecting with FBConnect.

LaNets’s picture

Status: Needs work » Patch (to be ported)

Hello EvanDonovan

Thank you for your help, I made the integration of your code in the latest dev version.
Check the CVS repository for lastest version.
Check project page for update instructions.
I hope it meets your. expectations

EvanDonovan’s picture

Thanks!

I will test the code when I get a chance. My organization has shifted priorities to doing a site upgrade to Drupal 6, so I don't know when I will have time to look at Facebook Connect integration again.

deathadder’s picture

Anyone still working on this? When someone has the same full name, then it won't register the user...

gallamine’s picture

Deathadder has a good point. How do you prevent duplicate usernames?

Rhino’s picture

subscribing

nirad’s picture

subscribing. would love to see this developed for the 1.0 version.

yngens’s picture

subscribe

EvanDonovan’s picture

Status: Patch (to be ported) » Active

There's not actually a patch here. Changing status accordingly.

EvanDonovan’s picture

Status: Active » Patch (to be ported)

Oh wait...the maintainer said it was in CVS. Not a patch strictly speaking then, but there is at least something to go off of. I haven't actually used this module in years though - we went with another solution.

gobinathm’s picture

Status: Patch (to be ported) » Closed (outdated)

Closing the issue. It was inactive for a long time & it's related to a Drupal Version which is not supported anymore