Hi,

While trying to edit a user account via the administration panel, I noticed I was unable to add twitter accounts. I did not have the time yet to make a diff but here is what should fix it.

twitter.pages.inc on line 304

function twitter_account_form_submit($form, &$form_state) {
  module_load_include('lib.php', 'twitter');
  module_load_include('inc', 'twitter');

  $name = $form_state['values']['screen_name'];
  $twitter = new Twitter($name);
  $account = $twitter->users_show($name, false);
  $account->set_auth($form_state['values']);
  twitter_account_save($account, TRUE);
}

becomes

function twitter_account_form_submit($form, &$form_state) {
  module_load_include('lib.php', 'twitter');
  module_load_include('inc', 'twitter');

  $user = user_load($form_state['values']['uid']);
  
  $name = $form_state['values']['screen_name'];
  $twitter = new Twitter($name);
  $account = $twitter->users_show($name, false);
  $account->set_auth($form_state['values']);
  twitter_account_save($account, TRUE, $user);
}

Hope this helps anyone.

Comments

juampynr’s picture

Status: Active » Closed (duplicate)

There were errors related to add an account fixed at #1253008: Twitter crashes when adding an account without password and #1192138: Error when adding/associating a Twitter account to a site account.

Please do upgrade to the latest stable version available at http://drupal.org/project/twitter.

Cheers

cwithout’s picture

Status: Closed (duplicate) » Active

I installed the latest stable version yesterday and noticed this same issue. Those other 2 are not related.

When an administrator attempts to add a Twitter account to another user, it instead gets added to that administrator's account. As an administrative user, that's not how I'd expect it to behave. That also leaves administrators unable to add a Twitter account to other users without logging in as that user.

I also don't have time at the moment to turn the above into a patch, but upon a single glance, it looks like it would solve the issue.

juampynr’s picture

Title: Editing user via admin does not save twitter name » An admin who adds a Twitter account to a user gets it instead of him
Version: 7.x-3.0-beta3 » 7.x-3.x-dev
Status: Active » Fixed

Great spot, I could recreate this error on the Drupal 7 version when not using OAuth, and on the Drupal 6 version using OAuth.

Drupal 7 fix: http://drupalcode.org/project/twitter.git/commitdiff/94350659f58060ae7f7...

Drupal 6 fix: http://drupalcode.org/project/twitter.git/commitdiff/5c618b4c538cc26045a...

Thanks.

Status: Fixed » Closed (fixed)

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