admin管理员组文章数量:1336422
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 badges1 Answer
Reset to default 4The 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
}
本文标签: How do I find the bbpress forum ID for a forum in a buddypress group
版权声明:本文标题:How do I find the bbpress forum ID for a forum in a buddypress group? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742374982a2462981.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论