Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I like to show the total number of favorites for each individual activity post next to the favorite button just like it shows the number of comments right next to the comment button. Is this possible to implement?

share|improve this question
add comment

1 Answer

Unfortunately, it's not really feasible, based on the current implementation of activity favorites in BuddyPress. BP stores this data in a piece of usermeta called 'bp_favorite_activities', which is an array of activity ids. That makes it easy and fast to pull up a list of a given member's favorite activity items; but it makes it almost impossible to pull up a list of the members who have favorited a given activity item, since the data is stored in serialized arrays and can't be reliably or quickly queried properly.

If this is something that your site really needs, you might consider writing a small plugin that does the following:

  • creates a custom database table linking activity items and individuals
  • hooks to the bp_activity_add_user_favorite and bp_activity_remove_user_favorite and writes to/deletes from your custom table with the relevant info.

I bet this would be a very popular plugin if you wrote it up and made it publicly available.

If you wrote something really nifty, you might also consider submitting it as a BuddyPress patch.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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