WP-Twitter-ID Social Profiles Integration

A few days ago I wrote a post about a wordpress plugin that will add a twitter id field to the comments form and I was reporint two problems with it. One was solved in that post and for the second one I'm going to show you a solution in this post.

The Problem

The second problem was that the twitter id field was show assigned to a comment when a registered user was commenting.

Basically I needed a way to specify the twitter id of a registered user in the profile and then just make the WP-twitip-id plugin use that value form the profile. I could have done this by implementing the necessary code to show the field on the profile page and save it's value when the profile was saved but I was lazy and I wanted a quicker solution.

The Quick Solution

The quick solution was to install the Social Profiles plugin, set my twitter id in my profile and then do a simple modification to wp-twitip-id.

To make the modification just open wp-twitip-id.php in any editor, look for "function addtwitterfieldmeta($comment_data){" and right after that line insert the following code:

  1. if(!empty($_POST['atf_twitter_id'])){
  2. $twitter=$_POST['atf_twitter_id'];
  3. }else{
  4. $current_user = wp_get_current_user();
  5. $user_id = $current_user->ID;
  6. $twitter=get_usermeta($user_id,'cyc2_twitter');
  7. }

That's it. Simple don't you think ? Now next time you post a comment as a registered user you should see your twitter id in the comment header.

Download

Here's the zip file with all modifications including the one in the previous post.

WP-Twitip-ID-0.9.2 (13.3 KB)

2 thoughts on “WP-Twitter-ID Social Profiles Integration

Leave a Reply