webtechnick / CakePHP-Facebook-Plugin

CakePHP Facebook Plugin
http://facebook.webtechnick.com
445 stars 138 forks source link

How to check of beforeFacebookSave is being called? #99

Open timinho opened 11 years ago

timinho commented 11 years ago

I have the feeling the beforeFacebookSave isn't been called. I need to save a user's email, firstname and lastname so what I do now is:

$fb_array = $this->Connect->user();

if( !empty($fb_array) ) {
  $this->loadModel('User');
  $facebookuser = $this->User->find('first',array('conditions' => array('User.facebook_id' => $this->Connect->user('id'))));

  if(!empty($facebookuser)) {
    echo "Saving";
    $userupdate['User']['id'] = $facebookuser['User']['id'];
    $userupdate['User']['group_id'] = 3;
    $userupdate['User']['last_login'] = date("Y-m-d H:i:s");
    $userupdate['User']['email'] = $this->Connect->user('email');
        $userupdate['User']['firstname'] = $this->Connect->user('first_name');
        $userupdate['User']['lastname'] = $this->Connect->user('last_name');
        if($this->User->save($userupdate,false)) {
          echo "Saved";
        }
  }
}

I prefer to do this in the same update/insert query from the plugin. Any suggestion?

//Edit I'm using php 5.3, cake 1.3 and the latest version of the plugin 3.3.1