最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I find the bbpress forum ID for a forum in a buddypress group?

programmeradmin1浏览0评论

I am trying to modify this code / but I have specific questions and cannot find the answer. This code above generates a shortcode like [bbpress_recent_replies_by_topic show=10 forum=123]

I have a buddypress site with groups, and each group has its own bbpress forum. I want to list the recent replies for the forum assigned to that group (only) when a user visits the group page. So basically I want to assign the forum ID based on whichever group the user is in and is seeing the widget in.

This is the function in the code above:

function custom_bbpress_recent_replies_by_topic($atts){
    $short_array = shortcode_atts(array('show' => 5, 'forum' => false, 'include_empty_topics' => false), $atts);
    extract($short_array);

Instead of 'forum' => false, I want it to point to 'forum' => _bbp_forum_id or something like that. However, that doesn't work because I'm at the group home page so there is no forum there yet until you click "forums" in the group menu. I don't know how database links the budddypress group to the bbpress forum id.

Some questions: 1) How do I find out the forum id for the group’s assigned forum? Is it _bbp_forum_id ? 2) How do I then assign that forum ID to to be the default forum ID for the widget in the code above?

I am trying to modify this code https://www.daggerhart/bbpress-recent-replies-shortcode/ but I have specific questions and cannot find the answer. This code above generates a shortcode like [bbpress_recent_replies_by_topic show=10 forum=123]

I have a buddypress site with groups, and each group has its own bbpress forum. I want to list the recent replies for the forum assigned to that group (only) when a user visits the group page. So basically I want to assign the forum ID based on whichever group the user is in and is seeing the widget in.

This is the function in the code above:

function custom_bbpress_recent_replies_by_topic($atts){
    $short_array = shortcode_atts(array('show' => 5, 'forum' => false, 'include_empty_topics' => false), $atts);
    extract($short_array);

Instead of 'forum' => false, I want it to point to 'forum' => _bbp_forum_id or something like that. However, that doesn't work because I'm at the group home page so there is no forum there yet until you click "forums" in the group menu. I don't know how database links the budddypress group to the bbpress forum id.

Some questions: 1) How do I find out the forum id for the group’s assigned forum? Is it _bbp_forum_id ? 2) How do I then assign that forum ID to to be the default forum ID for the widget in the code above?

Share Improve this question asked Jun 4, 2020 at 13:40 GauravGaurav 236 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 4

The forum id for a group is stored in the {yourprefix}_bp_groups_groupsmeta table where group_id is the group id and the key is forum_id and the value is a serialized array.

Instead of a shortcode, it may be easier to add a function call in a bp groups template. Something like: echo gauray_recent_replies( bp_get_group_id() );

function gauray_recent_replies( $group_id ) {
   $forum_id = bbp_get_group_forum_ids( $group_id );
   // collect and return replies
}
发布评论

评论列表(0)

  1. 暂无评论