1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add Follow Me on Bookmarking_Post.php

Discussion in 'General Troubleshooting' started by angolanmade, Feb 20, 2012.

  1. angolanmade

    angolanmade Well-Known Member

    Hi I'm interested in finding out the easiest/best way to display a registered users twitter handle at the bottom of their posts:

    I know a user can simply add "Follow Me On Twitter" at the end, but is there a better way?

    Would it be possible to display their twitter handle based on custom user profile field?

    Thanks in advance!
    Last edited: Feb 21, 2012
  2. seekyt

    seekyt Donor Donor

    I think that the easiest way would be to add a field to the user's profile where they could insert their twitter username. Then, you could open bookmarking_post.php and insert a code that displays a link if the user has set their twitter name in their profile.

    I would do it like this:

    In plugins -> users -> templates -> users_edit_profile.php, right above where it says "add your own profile [something] stuff here:

    $profile['twitter'] = $h->cage->post->testAlnumLines('twitter');
    Then, a little further down that page, right after this:

    <textarea rows=5 name='bio'><?php echo $profile['bio']; ?></textarea>
    Insert this:

    <tr><td>Twitter Username: </td><td><input type="text" name="twitter" value="<?php echo $profile['twitter']; ?>"><br />Display a link to your Twitter account on your posts</td></tr>
    Then open bookmarking_post.php in plugins->bookmarking->templates-> bookmarking_post.php, and just after this:

    <?php echo ($h->post->content?>
    You could do something like this:

            if (isset(
    $h->vars['twitter']) && !empty($profile['twitter'])) { 
    $h->vars['twitter'] = $profile['twitter'];

    <a href="http://twitter.com/#/<?php echo $h->vars['twitter']; ?>/">Follow Me on Twitter</a> <?php ?>

    I haven't tested that yet, but I think it will work.
    Last edited: Feb 20, 2012
  3. angolanmade

    angolanmade Well-Known Member

    Hey seekyt

    Thank you for your input, I was under the impression that your suggestion would be the ideal way to go, however I have been unsuccessful in getting the twitter handle to work to display. is there anything missing from your example?

    Thanks in advance.
  4. seekyt

    seekyt Donor Donor

    Hmm, I don't think I left anything out, unless I made a typo. I use codes similar to that for all kinds of unique variables on my Hotaru site. Are you getting any errors in your error log? (Besides the "Undefined Index" errors that would be expected with this)

Share This Page