I'm new to the Twitter module and perhaps this should be obvious, but how do you set up a rule to post a message to the current user's Twitter account? At the moment, the form in the "Post a message to Twitter" action only permits a static screen name at rule creation time. I want to use a token for the current user's Twitter account. If the user has more than one account, for the moment it's ok to use the first.

I tried adding a custom token that queries the current user's screen_name and comment out the form check on lines 68-70 in twitter_actions.module to allow it to be used as the Twitter account name, but that doesn't seem to be enough. Any ideas?

Custom token code:

<?php
$sql
= "SELECT screen_name FROM {twitter_account} WHERE uid = %d";
$results = db_query($sql, $user->uid);
while (
$row = db_fetch_array($results)) {
   return(
$row[screen_name]);
}
?>

Comments

Title:Rules: post to current user's Twitter accountRules: Post to current user's Twitter account

escore,

Your custom token code worked brilliantly for me (granted just at first stages of testing). Many thanks!

All I had to do was remove the PHP encapsulation (<?PHP ?>) for the code and it worked great.

Much appreciated.

Rob

Category:support» feature

Version:6.x-3.x-dev» 7.x-5.x-dev

This logic was present on 6.x-3.x and got lost during the upgrade to Drupal 7. I will see how can we get it back.

Version:7.x-5.x-dev» 6.x-5.x-dev
Status:Active» Needs work

Added option [current user] at twitter_actions so modules Rules and Action can set it to use current user's Twitter account to post messages when available.

http://drupalcode.org/project/twitter.git/commitdiff/575faba

Status:Needs work» Fixed

Status:Fixed» Closed (fixed)

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