Twitter id comment field

I saw this post on problogger about how Darren implemented a new field in the comment form for his new blog about twitter tips powered by wordpress. Basically he used a plugin for adding and extra field to the comment form and then modified the comment template to show the link to the twitter profile page.

There are two problems with this approach. #1 Unlike the author name, email and web site, the twitter id field is not saved in a cookie so your comentators will have to fill it in every time they post a comment, this migh be annoying for some of them. the second problem is that if you're logged in and want to reply to a comment there's no way you can set the twitter id.

The first problem was almost solved by a new plugin named wp-twitip-id by Andy Baily specially created for setting up the twitter id field. I said almost solved because this plugin uses javascript to add the new field and in some cases ( depending on the template you are using ) javascript would not be the best way to do this.

Luckily you can use this plugin without javascript and add the new field manually by modifying the comments.php template file but then the cookie would not work anymore so it needs some modification to set the cookie from the php script instead of javascript .

Simply calling setcookie before the comment is saved will do the work, then when you display the form field just use $_COOKIE['atf_cookie'] to set the value of the twitter field.

If you like to modify some plugin code get the wp-twitip-id plugin, open wp-twitip-id.php look for addtwitterfieldmeta function and add

  1. span style="color: #ff0000;">'atf_cookie'

right after the line with this code: 'if($twitter){'

Then go into wp-content/themes/<yout_theme>/ edit comments.php  look for the URL field and add a new field after it like this:

<input name="atf_twitter_id" type="text" value="<?php echo $_COOKIE['atf_cookie']?>" />

You might have to add some other html code and css to make the field look like the others but that depends on the theme you are using.

For convenience I have attached the modified plugin but you still have to modify the comments.php file in your theme.
wp-twitip-id-091

Let me know how this works for you. Do you think the twitter id comment field is worth the effort ? Does it bring value to you it as a commentator?

3 thoughts on “Twitter id comment field

  1. I love it when people come up with great additions to my plugins! I’ll have a look at the code and see if I can add an option to check to see if the user has selected to use manual feed entry if I get time this week.

    of course, I’ll give you some credit in the source. there must be at least 3 people that see it 😀

    1. Thanks for the comment Andy. I also wrote about this on your forum before I posted on my blog. I just thought my post might help people having the same problem as I had.

      I’m also thinking about using the Social Profiles plugin or at least using it as inspiration for modifying your plugin for fixing the problem about no twitter id for registered users.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.