Add a twitter field to your comments in Hybrid Framework

Learn how to add a twitter field to your comments form in the Hybrid Framework, version 0.8 and WordPress 3.0.

You’ll notice that I’ve got this feature active on the site now. If you scroll down to the comments section, you, or any commenter can add his/her twitter handle that will attach to the comment.

Since I am using the Hybrid Theme, this tutorial is for it.

#1

First off, we need to grab the latest version of Twitter Link Comments. And of coarse be sure you’ve got the Hybrid Theme (version 0.8.x or greater) installed and activated. With Hybrid 0.8, you’ll need the latest trunk version of WordPress, which as of today happens to be 3.0, beta-2

#2

Ok, now that’s settled, I hope ;). We can move on the the options that Twitterlink has. Below you’ll see a bases for what you need to apply. We’ll turn off auto add twitter field, and apply the style and setting to how we want the link formation to be.

Twitterlink Comments Options Page
Twitterlink Comments Options Page

#3

Next, will moving into our functions.php file located in your child theme. No child theme being used? Well at the end of this tutorial will apply this function into a plugin!

Paste this function.

function add_twitter_id_field($fields) {
	$twitlink = get_option('twitlink');
	$fields[] = '<p class="form-twitter"><label for="twitter">Twitter <span class="required">* <em>Don′t use the @ symbol</em></span></label><input type="text" class="text-input" name="atf_twitter_id" id="atf_twitter_id" value="' . esc_attr( $twitlink['post_html'] ) . '" size="40" tabindex="4" /></p>';

	return $fields;
}

That’s it, the whole function. Now be sure to add the appropriate filter, which is:

add_filter( 'comment_form_default_fields', 'add_twitter_id_field' );

This function will filter in the new input with the ID of atf_twitter_id which the plugin Twitter Link Comments looks for to apply it’s twitter field magic.

Now, I’ve noticed that when an end user, or commenter comments multiple times that if inputting a different twitter handle the newest and latest gets applied to all previous comments. I sure there is a way around that, I’ve just not looking into it.

#done

Um, that’s a number, some times.

Anyway, that’s all you’ve got to do to add to add your users twitter handle and attach it to their comments.

Leave a comment below, and test it out!

Austin
Austin

πŸ’πŸ½β€β™‚οΈ Husband to Jeana.
⚾️ Dodgers & Brewers.
πŸ’» PHP Engineer.
πŸŒπŸΌβ€β™‚οΈGolfer; ~13 HDC.
🌱 Hydroponic Gardner.
🍿 Plex nerd.
πŸš™ '15 WRX, '22 Model 3 LR, & '66 Corvette C2.

Follow me on Twitter @TheFrosty & Instagram @TheFrosty.

Articles: 293

4 Comments

  1. Thanks for your writing. I’m using hybrid as plataform and now i’m looking forward for your next posts and tuts.

Comments are closed.