• Resolved TrishaM

    (@trisham)


    I manage a multi-author blog and would like to use this plugin to display in the sidebar the Twitter stream of the author being currently viewed.

    It seems like it should be a simple thing to set the variable this plugin uses ($username) to be equal to the author metadata (called ‘twitter’ which is from another twitter plugin that just adds that field that can then be used) like this:

    $username = the_author_meta(‘twitter’);

    But that does not work – the function runs but returns an error from Twitter because of a missing username – it only seems to work if you actually enter the username as this:

    $username = “twitterusername”;

    I’ve tried playing around with this for a couple of days with no success, but I’m sure it’s because I’m not a PHP coder, just capable of some minor tweaks to other’s code.

    Can anyone help me with getting this to work with the author meta data?

    http://wordpress.org/extend/plugins/twitter-for-wordpress/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter TrishaM

    (@trisham)

    Bump

    Thread Starter TrishaM

    (@trisham)

    Bump

    Thread Starter TrishaM

    (@trisham)

    With help from esmi, I modified the above code to use get_the_author_meta instead of the_author_meta

    That now inserts the variable as the username, and eliminated the error I was getting, but unfortunately it still does not display the twitter messages. Now I get “no public Twitter messages” even though there are plenty of public messages (tweets) that could/should be displayed…..

    So I’ve made enormous progress, just not all the way fixed yet….

    Thread Starter TrishaM

    (@trisham)

    I know there is another similar thread about this but that seems to be for individuals just trying to get it to work…..my problem is a little different.

    I need it to work for multiple authors, and display the twitter stream for the author whose page is currently being viewed…..

    I’ve tried using a variable to supply the twitter username (and also per a suggestion in the other thread, the actual number of the twitter user’s RSS feed) but it doesn’t work.

    If i put the variable in the page template, I get “RSS not configured”…..

    If I try to put the variable into the plugin code itself (using get_author_meta), it bombs because it doesn’t know the WP core functions…….

    SO how do I tell it to include the path to the WP core functions so it will recognize something basic like get_author_meta() ??

    I use the CIMY Extra Field Values plugin and add a field Twitter ID to the user profile. Then this code:

    <?php $twitter_id = get_cimyFieldValue(2, 'TWITTER-ID'); twitter_messages($twitter_id, 1, false, false, '#', true, true, false); ?>

    My site is setup in a way where I can manually specificy the user ID (e.g. 2) but there are ways around that.

    Thread Starter TrishaM

    (@trisham)

    Hi Joshkadis

    That is very similar to what I’m doing – I’m using a plugin that adds a field to the author meta called “Twitter” which is where you put in the twitter account name. It’s called Twitter User:
    http://www.bloggingtips.com/wordpress-plugins/twitter-user/

    So I tried something along the lines of what you did, but without the user ID (e.g. 2 from your example), because that is dynamic to whatever author’s page is being viewed…..instead I used code I got from the Codex page on the_author_meta()

    <?php if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin(get_the_author_login());
    else :
    $curauth = get_userdata(intval($author));
    endif;
    
    $twitter = $curauth->twitter; 
    
    twitter_messages($twitter, 1, false, false, '#', true, true, false); ?>?>

    But it doesn’t seem to work….if I put this in my template file (sidebar.php) where I want it, I get one of two error messages:
    – If I use the RSS feed # for the user as suggested in a different thread in this forum, I get “RSS not configured”

    – If I use the twitter account name for the user, I get “no public twitter messages”

    If I put that code in the actual plugin, it bombs with a PHP error because it doesn’t understand core WP functions.

    So I don’t know what else to try at this point……

    Any help would be much appreciated!

    Thread Starter TrishaM

    (@trisham)

    UPDATE: SUCCESS!!

    Joshkadis you helped more than you know!

    I looked more closely at what you are doing and noticed that in the twitter_messages function you did NOT use quotes around the twitter username variable you are using…

    Since I was trying to follow the instructions in the plugin, I DID have quotes around the variable name – I removed those and now it works! Perfectly!

    THANK you very much!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Twitter for WordPress] Help with modifying this for multiple authors’ is closed to new replies.