I wrote a module that shall set the local drupal username upon registration to the facebook name. I used the fb hook Operation FB_OP_PRE_USER and this code

# Implementation of Hook Facebook
function npfb_fb($op, &$data, $ret) {
  
  if ($op == FB_OP_PRE_USER) {
    $ret['username'] = $ret['info']['name'] . 'blabla';
    $ret['mail'] = 'someone@somewhere.con';   
    
    return $ret;
  }
  
  if ($op == FB_OP_POST_USER) {
        
    npfb_init_fb_user($data[account]); # do various init works
  }
}

The user is created but the username is always blank also I return some value (at least the username should be blabla. The problems seems to be in the function fb_user_create_local_user but I cant figure it out. The username is always blank, I would suggest that the username by default is the facebook real persons name.

Comments

scoorch’s picture

Oh and I have read the readme.txt from start to bottom ;-)

Dave Cohen’s picture

Category: bug » support
Status: Active » Fixed

That's not how hook_fb() works. It's not well documented...

Put the "&" in front of $ret...

function npfb_fb($op, $data, &$ret) {
...

}

And there's no need to return $ret;. Just modify it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.