Modifying WordTwit to add "by @user"

Being able to tweet out from WordPress automatically is a pretty useful thing. Luckily, a handy little plugin called WordTwit does that for you pretty well.

However, it's missing the ability to attribute the author via their Twitter name in the tweet. So, I hacked up a little modification to make that work....

First thing: go into WordTwit settings and change the message to include [author]

Pastedgraphic-1

Next step: download a plugin that lets users at their twitter usernames to their profile.

I used this plugin

Then: update your profile to add your twitter username

Pastedgraphic-2

After that: the hacking beings. (don't worry, its not very hard!)

Go into the plugins directory and inside of the wordtwit folder you will find wordtwit.php.

Edit the wordtwit_get_message function

Adding 

/* MODIFICATIONS BY SPENCER SCHOEBEN */
$userdata = get_userdata($my_post->post_author);
$twitter = $userdata->twitter;
$display_name = $userdata->display_name;

if ($twitter) {
$twitter = trim($twitter);
if (strpos($twitter, "@") !== 0) {
$author = "@".$twitter;
} else {
$author = $twitter;
}
} else {
$author = $display_name;
}

$message = str_replace( '[author]', $author, $message );
/* END MODIFICATIONS */

Pastedgraphic-3