Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Request: “Thank You button”


_ck_
Participant

@_ck_

This would be a good beginning project for a first bbPress plugin, I’d encourage you and just ask for help if you need it.

Basically you’d want to store within and display within the topic meta adding the user id number to a list so people can’t thank twice – or so you can list the names of those that thanked. Use “implode” and “explode” to make the list and count the names.

As a shortcut you could store the actual username and output the raw string with the commas to show all the names that thanked. Then by counting the commas (+1), or exploding into an array and counting the array, you’d get the number of people that thanked. You could give admin the option to show the list of names that thanked or just the count (or both).

The trickiest part is you have to give a button to thank with, which gives you either a form or an href. Then you have to look for the get/post data and process it. I recommend using a href via a GET instead of POST so bbPress doesn’t have to redirect to clear the post data (it’s nasty to reload twice).

I just realized you mentioned “posts” vs “topic” and the problem with that is that bbPress doesn’t have a per-post metadata table. This would make it a bit more complicated as you’d have to track which post number within a topic was thanked and store it in the topic’s meta anyway. But if somehow a post is moved to another topic, this becomes a problem as the meta would not move with it (rare but could happen with plugins like move-it).

Skip to toolbar