function twitter_signin_user in Twitter 6.4
Same name and namespace in other branches
- 6.5 twitter_signin/twitter_signin.module \twitter_signin_user()
- 6.3 twitter_signin/twitter_signin.module \twitter_signin_user()
Implementation of hook_user().
Relates a Twitter account with a created user account if the user signed in with Twitter and then created an account or logged in.
File
- twitter_signin/
twitter_signin.module, line 182 - Hook implementations for twitter_signin module.
Code
function twitter_signin_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
case 'login':
if (isset($_SESSION['twitter']['values'])) {
module_load_include('lib.php', 'oauth');
module_load_include('inc', 'twitter');
$key = variable_get('twitter_consumer_key', '');
$secret = variable_get('twitter_consumer_secret', '');
$response = $_SESSION['twitter']['values'];
$twitter = new Twitter6($key, $secret, $response['oauth_token'], $response['oauth_token_secret']);
$twitter_account = $twitter
->users_show($response['screen_name']);
$twitter_account
->set_auth($response);
twitter_account_save($twitter_account, TRUE, $account);
unset($_SESSION['twitter']);
drupal_set_message(t('You have related a Twitter account with your user. Next time you can sign in with Twitter.'));
}
break;
}
}