I would like to implement tag subscription and follow/nofollow for registered users.

I mean when the user goto tag page, left side widget should show subscribe/unsubscribe button.

And when the user goto author page, left side widget should show follow/nofollow button.

Front page posts should have two other tabs called "subscribed" and "following".

When the user click subscribed tab it should show the posts which contains user subscribed tags. Likewise following tab should only show user following author posts.

Is there any readymade plugin available??? If not can i use existing plugins like subscriber2 to implement this feature.

What are the steps? I should store the tag and author id in the database right?

PS: I don't want you to code my plugin. This is my first wordpress plugin which requires database related work. So i just wanna understand how the database works. I just want to know whether i should create a new table or can i use existing meta tables to implement this feature.
If i can use existing table which table i should use to store tag id and author id.

  • @Viruthagirl It would be best to rephrase your question to be more specific. Instead of asking someone to do the work for you, you should try implementing the concept yourself and use this forum if you get stumped. The community is all about helping, but the way your question comes across is that you want someone to do all the work for you. A simple edit might get you more answers. :) – Brian Fegter Feb 9 '12 at 15:03
  • Ok i'm not sure how to rephrase this question. I don't want stackexchange to do the job for me. This is my first plugin which requires database related work. I just want the procedure. I mean like which table i should use to store the value..etc.. – Giri Feb 9 '12 at 15:08
  • I'll make the edit for you. :) – Brian Fegter Feb 9 '12 at 15:12
  • Much better. :) – Brian Fegter Feb 9 '12 at 15:15
  • Sorry, but this question is still far too vague. Voted to close as "not a real question". – Chip Bennett Feb 9 '12 at 15:36

The way I would approach this is:

  • Create several AJAX calls using the nopriv hook bound to the subscribe/follow button clicks.
  • Within the PHP callback functions, I would insert value of the tag or the followed user into the logged-in user's meta using add_user_meta, get_user_meta, delete_user_meta.
  • Lastly, I would create a conditional function to use in your templates that pulls down the user meta, checks the current tags or users and then return a bool value so you can render the proper state of your buttons.

The AJAX PHP callback would use something like the following:

global $current_user;
$tags = get_user_meta($current_user->ID, 'tag_subscription');
if(in_array($tag_slug, $tags))
    //do something
    add_user_meta($current_user->ID, 'tag_subscription', $tag_slug, false);

To remove an element from the user meta array, you would do the following:

delete_user_meta($current_user->ID, 'tag_subscription', $tag_slug);

The conditional template tag would look like this in your template:

     //display this state of the button
     //display another state of the button

Hope this helps you out!

  • Thanks Brian, You posted a great answer and definitely it will help me. – Giri Feb 9 '12 at 17:37
  • Glad to help you! – Brian Fegter Feb 9 '12 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.