Step by step guide to setting up a bbPress forum – part 2

Step by step guide to setting up a bbPress forum – part 2

Step by step guide to setting up a bbPress forum – part 2
Codex Home → Step by step guide to setting up a bbPress forum – part 2
WHERE ARE WE?
Part 1 dealt with getting the forum going.
Part 2 deals briefly with plugins, but mainly with changes to styling and bbPress.css
Part 3 will dealt with layout and functionality.
The forum is now fully functional, but probably you』ll want to change some of how it looks. If you』re using anything but a default theme, I expect that the colors won』t look right, and you may want to change some fonts.
You may also want to change where elements are displayed. Or add other functions to your site.
So there are two types of change we might want to make to our site –

changes in style – how it looks, and
changes in functionality – how it works.

Changing bbPress to achieve both these can consist of 4 things:
1. Changing CSS
2. Adding Plugins
3. Changing function files
4. Changing PHP files
This part 2 deals with changes in style which means primarily changing css.
Summary for techies
If you』re already into css, then bbpress uses by default a file called bbpress.css located in wp-content/plugins/bbpress/templates/default/css
Either just override styling in your theme』s css, or copy the bbpress.css file to a folder
/wp-content/themes/%your-theme%/css/
and bbpress will use that file, so make changes there.
A quick bbpress styling crib is available to get you started.
1. What is css?
CSS stands for Cascade Style Sheet – it』s a simple way to define elements of the site that will be used often. For instance if parts of your website have a heading, then defining a heading style once (font size, color, font used, bold, italic etc.), and then simply referring to it each time a heading is displayed is much easier than defining it each time.
Now we can override the default CSS elements in 4 ways

With a css plugin
Adding code to our child theme』s style.css
Copying/creating a bbpress stylesheet in your child theme
With functions (see below)

2. Using a CSS plugin
There are several around, including https://wordpress.org/plugins/simple-custom-css/ just google 『WordPress css plugin』 to find one right for you.
Using these you can add css to your site without needing to code in files, and if you』re only doing a few small changes, this can be an easy way without fearing that you』ll ruin a file on your website.
However if you doing all but a few small changes, you would be better looking at the remaining options
So in this section we』ll deal with b & c.
But before we do that, we need to understand a bit more about how to change files without losing our work later on.
3. Changing files Overview – get a child theme !
To make bbPress work or look better without plugins, we』ll need to change files.
Now if we simply change the files in bbPress, then any updates to bbPress will risk losing these changes, and undoing all your hard work.
So we will make changes in our WordPress themes, leaving alone the bbpress plugin directory.
If you』re in to writing your own WordPress themes, then I suspect you』ll be skim reading this article, so the next bit is for those of you that are either using a WordPress default (twentyten, twentyeleven etc.) or have chosen one of the many free or paid for themes.
If you have gone for any of the above, then again if you simply make changes to the theme, then any updates to your theme will risk losing these changes, and again undoing all your hard work.
If you are a bit more advanced, you may already have a child theme, and it is here that we』ll make additions and changes. That way updates will not affect lose the changes we have carefully crafted.
If you don』t currently have a WordPress child theme, then the best way to proceed is to create one, and then you can make changes there.
If you don』t know how to create one, the WordPress Child Theme training module is a great place to start, also search google 「child theme wordpress video」 and you』ll find lots of demonstrations. If someone has built a site for you, it may already be a in a child theme, and again the video』s will let you see whether this is the case.
So let』s presume you now have a child theme…
bbPress picks on the styles used in your theme for some elements, but uses its own CSS style sheet for others. This default css works well with the wordpress twentyten theme, but may not look right with your theme.
4. Adding code to our child theme』s style.css
If you』re making just a few changes, then adding the code to your child theme』s style.css is the easiest way to go
We』ll come later to the key bits of code you might want to change, but for the moment let』s suppose that you don』t like the way bbPress lists the forums.
The default looks like :

And you』d like it to look like :

This element is styled in the original bbPress.css file as followed
#bbpress-forums .bbp-forums-list li {
display: inline ;
font-size: 11px;
}
Changing the 『display:inline』 to 『display:list-item』 will achieve this. But as we said above, whilst you could simply amend line 121 (in wp-content/plugins/bbpress/templates/default/css/bbpress.css) you don』t want to alter this, as upgrades to bbPress versions might well overwrite this.
So we simply enter the appropriate code in our child theme』s style.css.
We can enter the entire 「chunk」 of code, and if you』re copying from bbpress.css, then copying the entire chunk and then altering just the bits you want will help you remember what other parameters are there
So
#bbpress-forums .bbp-forums-list li {
display: list-item !important;
font-size: 11px;
}
achieves this. Equally well you could post
#bbpress-forums .bbp-forums-list li {
display: list-item !important;
}
ie just the bits of the code that you actually want to change.
NOW you may have spotted that I』ve added 『!important』 to the line. This is because our theme style.css file will execute first, then the bbpress.css (being a plugin) will execute afterwards. Since the later bbpress.css file contains the original code, this will simply overwrite the changes you have made. By entering 『!important』 to the line, you tell WordPress not to allow this code to be overwritten by later code, so preserving your change.
So that』s method 1, using your child theme』s style.css.
5. Copying/creating a bbpress stylesheet in your child theme
The alternative method is to either take a copy of bbpress』 default css or create a brand new one, and put this in a specific area of your theme that bbpress looks for.
For .css files, bbpress looks at you theme files in the following location :
/wp-content/themes/%your-theme%/css/
where %your-theme% is the actual directory name of your theme.
So any .css file found in this location will be used. I am not sure if this is instead of the bbpress.css file in the plugin default location or in addition to it. You will need to check that yourself, as at the time of writing I have not!
So your best bet is to copy the bbpress.css from wp-content/plugins/bbpress/templates/default/css/bbpress.css
To a directory called css as above in your theme directory.
You can then edit this theme to your heart』s content, knowing that it won』t be overwritten by any bbpress upgrades.
So if you』re now ready to start changing code but what can you change?
See bbPress styling crib to get you started.
6. Changing colors
For people starting out with css, knowing what exact color something is  can be tricky. So if your main theme has a background of a light blue – how do you get that exact same shade in bbpress.
More technical people will use features within browsers to show them the underlying information. For instance many people use a product called 「firebug」 with a Firefox browser to show them exactly what is happening, including what exact colours are being used for text and backgrounds. These tools can be extremely useful as you progress, and it』s worth getting to know them if you plan more than a couple of changes. Google 「firebug video」 to get lots of help such as Firebug tutorial
An alternative if colors are what you』re after is to use a product like colorcop which will let you see exactly what color is being used on any part of your screen, so copying either your own theme』s colors or someone else』s is really easy.
The next section deals with changing layout and functionality part 3

bbp_reply_author_link

bbp_reply_author_link

bbp_reply_author_link
Codex Home → bbp_reply_author_link
Description
The 『bbp_reply_author_link』 function is used to display the current reply author』s user role, avatar and username linked to their profile
Where is it used
Templates: loop-single-reply.php loop-search-reply.php
How to use it
1
$args (optional) – Accepts an array of arguments to configure display ( post_id, link_title, type, size, sep, show_role )
Uses bbp_get_reply_author_link()
Sample code example
1
Displays the linked avatar and username for the current reply author
1 '
', 'show_role' => true ) ); ?>
Displays the current reply author and user role separated by an HTML
element
1 '
', 'show_role' => true, 'size' => 32 ) ); ?>
Displays the current reply author and user role separated by an HTML
element and sets their avatar to a size of 32px wide and 32px tall
1 '
', 'show_role' => false, 'type' => 'avatar' ) ); ?>
Displays only the current reply author user』s avatar without their display name or user role
1 '
', 'show_role' => false, 'type' => 'name' ) ); ?>
Displays only the current reply author user』s display name without their avatar or user role
Related
bbp_author_link()
bbp_topic_author_link()

Step by step guide to setting up a bbPress forum – part 3

Step by step guide to setting up a bbPress forum – part 3

Step by step guide to setting up a bbPress forum – part 3
Codex Home → Step by step guide to setting up a bbPress forum – part 3
Part 2 of the guide dealt with styling changes.
This part will deal with changing what appears and where it appears – changing some of the functionality of bbPress.
Now you can alter functionaility in many ways. These include
1. with plugins
2. with functions
3. by changing bbPress files
4. adding filters
5. adding hooks
1. Plugins
If you』re not familiar with coding, then plugins can offer a great way to add functionality without needing to do coding. There are lots around, if you』re after something it』s always worth trying a google search with 「bbpress plugin」 and whatever you are after.
Some I have used include :
bbP signature – lets users add a 『signature』 to their posts – used a lot in forums
bbP topic views – displays how many times a topic has been viewed
and ones that might well be useful, but I haven』t used :
bbpress-notify – notifies admins, moderators etc. (fully configurable to role) when new post and replies are made
The rest of this part will assume that you have a child theme, if you』re not familiar with what this is and why you need it, please visit part 2 of this guide where it is all explained.
So lets assume you have a child theme.
2. Functions
A short guide on how to create a child theme and functions file can be found here
Functions files and child themes explained
3. Changing bbPress files
This part of the guide is primarily going to deal with the bbPress templates that the default bbPress plugin uses to display your forum.
NOTE: This part deals with changing templates that belong to the bbPress Plugin, and these changed templates should then reside within a bbpress folder in your theme.  HOWEVER if you create a bbpress.php file from a theme template or php file (that is a file that sites in your theme such as page.php) , then this resides in your theme』s root.  So if the source is the plugin, then bbpress folder;  if the source is your theme, then your theme folder !
Changing these files gives you a powerful way to improve how your forum works for your users, and in some cases making it easier for you to administer.
In part 2 we explained how changing files in the bbPress plugin was not a good idea, and these files are frequently overwritten on an upgrade. So to change files, you』ll need to copy them you your child theme.
Bbpress will normally use the default files found at
wp-content/plugins/bbpress/templates/default/bbpress
However if you create a directory in your child theme at
/wp-content/themes/%your-theme%/bbpress/
(where %your-theme% is your child theme』s name)
then any files stored there will be used instead.
This means that if you want to alter how a topic displays, then copying the relevant file (in this case loop-single-reply) to this folder will mean that bbPress uses this file instead, so you can now alter it to work how you want.
There are two sources that you might want to use for files – one is at
wp-content/plugins/bbpress/templates/default/bbpress
For instance in this bbPress folder you』ll find
loop-single-reply – this file displays a topic and all its replies letting you change the heading and the format within a post – for instance removing the avatar or adding extra words below it.
If you want to alter lower level files, then the other source is
wp-content/plugins/bbpress/templates/default/extras
Here you can alter for instance whether a single topic has a footer.
To alter any of these lower level files they need to be copied to the root of your child theme that is to
/wp-content/themes/%your-theme%/
(where %your-theme% is yout themes name).
So bbPress offers a simple way to change the layout and information displayed.
As an example, the default forum display looks like

which displays the forum counts for the sub-topics.
If you wanted to take these out to look like

Then you would need to change
loop-single-forum.php by changing how the code displays
so you would change line 44  from
 

 
to read
 
false,
『show_reply_count』    => false,
『separator』 => 」,
));  ?>
 
So copy the file loop-single-forum.php from wp-content/plugins/bbpress/templates/default/bbpress to /wp-content/themes/%your-theme%/bbpress/
and add the above function. Then save, and hey presto, the counts have gone !
For some starters on what you might want to change have a look at Layout and Functionality – Examples you can use
Part 4 deals with adding actions and
Part 5 deals with adding filters

bbp_topic_author_link

bbp_topic_author_link

bbp_topic_author_link
Codex Home → bbp_topic_author_link
Description
The 『bbp_topic_author_link』 function is used to display the current topic author』s user role, avatar and username linked to their profile
Where is it used
Templates: content-single-topic-lead.php
How to use it

$args (optional) – Accepts an array of arguments to configure display ( post_id, link_title, type, size, sep, show_role )
Uses bbp_get_topic_author_link()
Sample code example

Displays the linked avatar and username for the current topic author
'
', 'show_role' => true ) ); ?>
Displays the current topic author and user role separated by an HTML
element
'
', 'show_role' => true, 'size' => 32 ) ); ?>
Displays the current topic author and user role separated by an HTML
element and sets their avatar to a size of 32px wide and 32px tall
'
', 'show_role' => false, 'type' => 'avatar' ) ); ?>
Displays only the current topic author user』s avatar without their display name or user role
'
', 'show_role' => false, 'type' => 'name' ) ); ?>
Displays only the current topic author user』s display name without their avatar or user role
Related
bbp_author_link()
bbp_reply_author_link()
bbp_show_lead_topic()

bbPress 样式参考

bbPress 样式参考

本指南将向您展示新 bbPress 论坛的区域,您可以使用 CSS 以及 bbPress 插件中使用的类和选择器来设置每个区域的样式。

设计您的论坛

这些可以添加到您的 css 中,或添加到 bbpress.css 的自定义版本中 – 请参阅设置 bbpress 论坛的分步指南第 2 部分了解更多信息。

论坛婴儿床

论坛

bbPress 论坛中的所有内容

这是用于 bbPress 论坛所有部分的 CSS 。根据您的需要增加字体大小。

#bbpress-forums {
background: transparent;
clear: both;
margin-bottom: 20px;
overflow: hidden;
font-size: 12px;
}

1. 论坛页眉和页脚

这是显示作者、帖子和声音等标签的内容。

#bbpress-forums li.bbp-header,
#bbpress-forums li.bbp-footer {
 background: #f3f3f3;
 border-top: 1px solid #eee;
 font-weight: bold;
 padding: 8px;
 text-align: center;
}


#bbpress-forums li.bbp-header {
 background: #eaeaea;
}

2. 回复标题

#bbpress-forums div.bbp-reply-header {
    background-color: #f4f4f4;
}

3. 模板通知信息

div.bbp-template-notice.info {
    border: #cee1ef 1px solid;
    background-color: #f0f8ff;
}

4. 话题/回复背景

赔率,即使如此回复也有交替的颜色

#bbpress-forums div.even,
#bbpress-forums ul.even {
 background-color: #fff;
}


#bbpress-forums div.odd,
#bbpress-forums ul.odd {
 background-color: #fbfbfb;
}

如果话题很粘或超级粘,那么

.bbp-topics-front ul.super-sticky,
.bbp-topics ul.super-sticky,
.bbp-topics ul.sticky,
.bbp-forum-content ul.sticky {
 background-color: #ffffe0 !important;
 font-size: 1.1em;
}

自定义关闭话题文本的颜色。

#bbpress-forums .status-closed,
#bbpress-forums .status-closed a {
 color: #ccc;
}

每个线程的线程回复边距。

#bbpress-forums ul.bbp-threaded-replies {
 margin-left: 50px;
}

5. 各种文字

这些通常继承自您的主题。

但是,您可以使用修改内容

#bbpress-forums .bbp-topic-content,
#bbpress-forums .bbp-reply-content {
    font-size: 12px;
}

上面的代码不在 bbpress.css 中,因此如果需要,请添加它,或放入您的 .css 中,请参阅顶部提到的指南以获取更多信息

6. 管理链接

span.bbp-admin-links {
 float: right;
 color: #ddd;
}


span.bbp-admin-links a {
 color: #bbb;
 font-weight: normal;
 font-size: 10px;
 text-transform: uppercase;
 text-decoration: none;
}

7. 模板通知

div.bbp-template-notice,
div.indicator-hint {
 border-width: 1px;
 border-style: solid;
 padding: 0 0.6em;
 margin: 5px 0 15px;
 border-radius: 3px;
 background-color: #ffffe0;
 border-color: #e6db55;
 color: #000;
 clear: both;
}
div.bbp-template-notice a {
 color: #555;
 text-decoration: none;
}
 div.bbp-template-notice a:hover {
 color: #000;
 }
 div.bbp-template-notice.info {
 border: #cee1ef 1px solid;
 background-color: #f0f8ff;
 }
 div.bbp-template-notice.important {
 border: #e6db55 1px solid;
 background-color: #fffbcc;
 }
 div.bbp-template-notice.error,
 div.bbp-template-notice.warning {
 background-color: #ffebe8;
 border-color: #c00;
 }
 div.bbp-template-notice.error a,
 div.bbp-template-notice.warning a {
 color: #c00;
 }
 div.bbp-template-notice p {
 margin: 0.5em 0 6px 0 !important;
 padding: 2px;
 font-size: 12px;
 line-height: 140%;
 }

8. 从您的主题继承的面包屑和链接颜色

9. 其他造型功能

9.1 提交按钮

正在寻找一种方法来更改 bbpress 、更大、颜色中的提交按钮......?

#bbpress-forums .submit {
    background-color: #a0668d;
    color: #FFFFFF;
    float: center;
    vertical-align: middle;
    border-radius: 10px;
    height: 35px;
    width: 80px;
    font-size: 18px;
}

并更改为您想要的!

10. 从最近的话题小工具和新鲜度中删除头像

widget_display_topics .bbp-author-avatar {
    display: none ! important;
}


.bbp-topic-freshness-author  .bbp-author-avatar {
    display: none ! important;
}

Feature Plugins Tracking

Feature Plugins Tracking

Feature Plugins Tracking
Codex Home → Feature Plugins Tracking
Here are some bbPress plugins that we think are could enhance your forums and that we may consider adding to the core of the bbPress plugin.
You should also search through our plugin section here. If what you are looking for is not listed in the featured plugins below please note that since the latest version of bbPress is now a plugin of WordPress , that if a WordPress plugin does not mention bbPress or tag bbPress that doesn』t mean it』s not compatible with bbPress. For example any anti-spam plugin like Akismet , or any social registration/simple registration plugin in the WordPress repository should work fine with bbPress.
_______________
Legend:
(U) – Link to trac ticket where this or similar functionality is being under consideration/discussed
(X) – might not work/ might need to be forked
(C) – Link to trac ticket where it is planned for Core
_______________

bbPress – Numeric ID Permalinks
bbPress – Topic Lock
bbPress – Topic Count (C)
bbPress – Last Post (U)
bbPress – Canned Replies
bbPress – Notices
bbPress – Private Replies
Voter Plugin
WP ULike
bbPress – Ajax Replies and bbPress – Ajax Topics
bbPress – Additional Shortcodes
bbPress – Attachments (U)
bbPress – Tools (U)
bbPress – Quotes or bbPress – Direct Quotes (U)
bbPress – Avatar or Basic User Avatars
bbPress – Forum Redirect
bbPress – Report Abuse or bbPress – Report Content
bbPress – Ignore User
bbPress – Polls
bbPress – Messages
bbPress – HashBuddy
bbPress – Live Preview (U)
bbPress – Spam Cleaner (U)
Razz BBPress Suspension (U)
bbPress – Topics for Posts (C)
bbPress – user online status (U)
bbPress – Topic Subscribers

bbPress – Support Forums (U)

Buddy-bbPress Support Topic
EDD bbPress Support Dashboard
bbResolutions (GitHub)
bbPress – VIP Support (X) (GitHub fork with updates here, and here)
bbPress – Simple Support

bbPress – Unread / Mark as Read plugins (U)

bbPress – Pencil Unread
bbPress Go To First Unread Post
bbPress – Mark as Read
bbPress Unread Posts (forked version 2 of plugin here )
bbPress New Topics
djb bbPress last read plugin (X)

_______________
This is just plugins to highlight for bbPress plugin/theme developers that have specific features for the development of bbPress.
bbPress – Development

bbPress – Slack Integration
bbPress – Monster Widget
Buddy-bbPress Visual Hooks
Query Monitor with Query Monitor bbPress & BuddyPress Conditionals
Debug Bar with Debug Bar bbPress

布局和功能 - 您可以使用的示例

布局和功能 - 您可以使用的示例

您可以使用 WordPress 和 bbPress 提供的钩子和过滤器以多种方式自定义和扩展 WordPress 和 bbPress,还可以将一些 CSS 应用到您的论坛或主题。

下面是一些常用的自定义 PHP 和 CSS 代码片段列表,这些代码片段可能对社区用户自定义他们现有的 bbPress 论坛有用。

如果您发现列出的示例似乎不起作用,您想建议另一个有用的示例,或者使用不同/更好的方法来编辑当前的最终功能,然后请进入支持论坛并在论坛请求和反馈

1. 更改论坛列表的显示方式

默认看起来像: 论坛2

改成 : 论坛3

默认情况下,此元素使用 CSS 设置样式。

#bbpress-forums .bbp-forums-list li {
display: inline;
}

将此 CSS 代码片段粘贴到您的子主题的 style.css 并更改 display:inline 为 display:block 将实现此布局。

您也可以改用 PHP 代码片段,并将以下函数放入您的子主题 functions.php 文件中。

//create vertical list subforum layout
function custom_bbp_sub_forum_list() {
  $args['separator'] = '
';
  return $args;
}
 add_filter('bbp_after_list_forums_parse_args', 'custom_bbp_sub_forum_list' );

2. 从论坛列表中删除话题/回复计数

默认 :

论坛c
更改为:
论坛b
您可以更改 loop.single.forum.php,如 https://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum-part-3/ 所示或者

将以下内容放入您的子主题 functions.php 文件中。

function remove_counts() {
    $args['show_topic_count'] = false;
    $args['show_reply_count'] = false;
    $args['count_sep'] = '';
return $args;
}
add_filter('bbp_before_list_forums_parse_args', 'remove_counts' );

3. 向登录小工具添加 「修改个人资料/密码」

虽然您可以单击 bbPress 登录小工具中显示的头像或您的用户名转到您的个人资料,然后从那里单击编辑链接来编辑您的个人资料,但这对您的某些用户来说可能并不那么明显。

安装这个插件 RKK Login Widget,它几乎与默认的 bbPress Login Widget 完全相同。只需将 (RKK) 登录小工具放置到侧边栏之一,您的登录小工具就会与此类似。

论坛

根据需要自定义或编辑插件。

4. 关闭或更改面包屑

要删除论坛中的面包屑,请确保将此功能添加到子主题或功能插件中的 functions.php 文件中。

add_filter( 'bbp_no_breadcrumb', '__return_true' );

要自定义您要显示的特定面包屑链接的布局,请将其添加到您的子主题 function.php 文件中。

function mycustom_breadcrumb_options() {
    // Home - default = true
    $args['include_home']    = false;
    // Forum root - default = true
    $args['include_root']    = false;
    // Current - default = true
    $args['include_current'] = true;


    return $args;
}
add_filter('bbp_before_get_breadcrumb_parse_args', 'mycustom_breadcrumb_options');

5. 移除论坛搜索功能

如果您想删除搜索栏 (有些人喜欢要么排除它,要么把它放在侧边栏中)

默认情况下,搜索表单将显示如下。
论坛

这是之后的结果。
论坛

然后只需更改仪表盘> 设置> 论坛功能中的设置并取消勾选
Allow forumwide search 。

6. bbpress 后加载样式表

介绍:当 WordPress 加载样式表时,它们会先加载所有 theme.css 文件,然后再加载插件 css 。这样插件 css 的优先级高于您的 css,唯一可以覆盖它的方法是使用 !important 。众所周知,这是一种不好的做法。

此外,您可以在您的主题中创建自己的 bbpress.css ,但这意味着需要处理更多文件 (尽管这是最干净的解决方案) 。这是执行此操作的另一种方法:

将此代码粘贴到您的子主题 functions.php 文件中。

/** * load custom bbpress css after bbp default css */ wp_enqueue_style( 'custom-bbpress', get_stylesheet_directory_uri() . '/css/custom-bbpress.css',array('bbp-default'),'1.1','all');

7. 如何从模板中删除所有面包屑并将它们设置在页面顶部?

由 Markic 提交并感谢

简介:我们中的许多人正在使用标题中的现有面包屑系统创建自己的主题。但是 bbPress 有自己的想法在哪里显示面包屑,有时在页面顶部,有时在搜索表单下方,有时在标题下方。这是您可以快速更改的方法。

1. 如果还没有,请在主题的根文件夹中创建 「bbpress.php」 。
2. 添加

<div class="truebreadcrumbs"><?php bbp_breadcrumb(); ?></div>

3. 添加此 CSS:

div.bbp-breadcrumb {
 display: none; /*this will hide all breadcrumbs*/
 }


.truebreadcrumbs div.bbp-breadcrumb {
 display: block; /*this will display breadcrumbs you've created*/
 }

当然,HTML 仍然会生成所有的面包屑,而 css 会隐藏不需要的面包屑,但这是最简单的方法,无需进入模板。

8. 将 「编辑个人资料」 添加到 wordpress 菜单

大多数 bbPress 用户都有侧边栏,并使用小工具来控制登录和个人资料更改。其他人则依赖于用户知道如果点击他们的头像或用户名,那么他们就可以编辑他们的个人资料。

此解决方案允许您将 「编辑个人资料」 添加到您的 wordpress 菜单中——这仅在用户登录时显示为菜单项。

将以下内容添加到您的函数文件中

// Filter wp_nav_menu() to add profile link
add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
function my_nav_menu_profile_link($menu) {
    if (!is_user_logged_in())
        return $menu;
    else
        $current_user = wp_get_current_user();
        $user=$current_user->user_nicename ;
        $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
        $menu = $menu . $profilelink;
        return $menu;


}

9. 将社交媒体联系人添加到 bbPress 个人资料

感谢 nicmare 提供这个方便的提示。

您可以通过将这些添加到 contactmethods 来添加和删除社交媒体联系人。

以下示例函数添加了 twitter 、 facebook 、 google+ 和 youtube,但删除了
目标、 yabber 和 yim 。

function add_extra_contactmethod( $contactmethods ) {
// Add new ones
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['googleplus'] = 'Google Plus';
$contactmethods['youtube'] = 'Youtube';


// remove unwanted
unset($contactmethods['aim']);
unset($contactmethods['jabber']);
unset($contactmethods['yim']);


return $contactmethods;
}
add_filter('user_contactmethods', 'add_extra_contactmethod');

10. 缩短新鲜度的措辞

此代码缩短新鲜度取出分钟

只需将其放入您的函数文件中

//function to shorten freshness display from say '1 month, 2 weeks' to '1 month'
function short_freshness_time( $output) {
$output = preg_replace( '/, .*[^ago]/', ' ', $output );
return $output;
}
add_filter( 'bbp_get_time_since', 'short_freshness_time' );
add_filter('bp_core_time_since', 'short_freshness_time');

11. 简单地在菜单中添加登录/注销

为用户添加用于登录/注销、注册或恢复其密码的菜单项到您的站点菜单非常有用,尤其是在您决定不使用 bbPress 侧边栏登录小工具的情况下。

将以下 php 代码片段粘贴到您的子主题的 functions.php 文件中。

add_filter( 'wp_nav_menu_items', 'rkk_add_auth_links', 10 , 2 );
function rkk_add_auth_links( $items, $args ) {
 if ( is_user_logged_in() ) {
 $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
 }
 elseif ( !is_user_logged_in() ) {
 $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
 $items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';
 $items .= '<li><a href="'. site_url('wp-login.php?action=lostpassword') .'">Lost Password</a></li>';
 }
 return $items;
}

您可以根据自己的喜好自定义此功能。如果您想将某些 url 链接到自定义前端表单而不是默认的 WordPress 登录表单,您可以进行这样的简单更改,例如。

site_url('wp-login.php') 对此 site_url('/login/')

如果您想在注销后重定向到自定义 url 。

wp_logout_url() 把这个改成这个 wp_logout_url( site_url('/logout/') )

或者,如果您想在特定菜单中显示这些菜单项,请在 之后的函数中编辑两个条件 is_user_logged_in() 。

像这样添加到现有的条件中,is_user_logged_in() && $args->theme_location == 'primary-menu'.

上面的代码将在您的功能条件中显示特定菜单中的菜单项,其中主题位置通常是菜单段。要查找此功能的菜单的 slug/主题位置搜索,通常位于主题 functions.php 文件中 register_nav_menu() 。有关了解 register_nav_menu() 函数的更多信息,请参阅 WordPress 指南导航菜单

12. 添加模态 (弹出) 登录

这非常好,说明将其添加到菜单中,并根据需要使用登录/注销。

登录看起来像这样

模态登录3

有不同的风格可供选择,您可以设计自己的风格。

说明可以在这里找到

13. 防止关闭的话题变灰

默认情况下,关闭回复的话题是 「灰色的」 。但通常您只是想停止发帖,最常见的是针对论坛顶部的热门话题。

将此代码添加到主题中的 css 或修改主题 css 文件夹中的 bbpress.css 。

#bbpress-forums .status-closed,
#bbpress-forums .status-closed a {
  color: #aaa !important;
}

14. 添加新的 bbpress 角色

您可以添加新的 bbpress 角色,甚至更改其功能。

在最简单的级别上,您可以添加新角色名称并为其赋予现有能力

这仅对您自己的管理目的很有用,但如果像我一样讨厌 「keymaster」 角色名称,只需创建一个新角色并为其赋予 keymaster 功能。

以下代码创建了三个名为 「name 1」 、 「name 2」 和 「name 3」 的新角色,第一个角色有参与者、第二个主持人和第三个关键管理员。

只需修改代码即可创建具有您需要的任何功能的任意数量的角色

function add_custom_role( $bbp_roles ) {


$bbp_roles['my_custom_role1'] = array(
'name' => 'name 1',
'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles['my_custom_role2'] = array(
'name' => 'name 2',
'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles['my_custom_role3'] = array(
'name' => 'name 3',
'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() ) // the same capabilities as keymaster
);
return $bbp_roles;
}
add_filter( 'bbp_get_dynamic_roles', 'add_custom_role', 1 );

15. 在 bbpress 角色中添加自定义功能

添加自定义功能

16. 论坛页面添加说明

如果您创建一个带有描述的论坛,这只会显示在主索引页面上,而不显示在类别页面或论坛页面上

从:

说明1

到 :

说明2

将以下内容添加到您的函数文件中。

//filter to add description after forums titles on forum index
function rw_singleforum_description() {
  echo '<div class="bbp-forum-content">';
  echo bbp_forum_content();
  echo '</div>';
}
add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');

我还添加了这个自定义 CSS 。将此添加到您的子主题的 style.css 文件中,以将其放置在面包屑下。

#bbpress-forums div.bbp-forum-content {
  clear: both !important;
  margin-left: 0 !important;
  padding: 0  !important;
}

17. 将订阅移至右侧

改变
订阅1

到:

订阅2

将以下内容放入您的 style.css

/*styling to move 'Subscribe' to right hand side */
.single-forum .subscription-toggle  {
    float:right !important ;
}

如果您只想将其稍微向右移动,则可以使用此自定义 CSS 。根据您的喜好调整 5px 。

/*styling to move 'Subscribe' to right hand side */
.single-forum .subscription-toggle  {
    padding-left: 5px !important ;
}

18. 防止用户更改他们的显示名称

用户可以在 bbpress 个人资料页面中更改他们的显示名称。一些论坛希望阻止这种情况以阻止用户隐藏他们的身份。

要关闭此功能,您需要编辑默认文件之一并将其保存到您的主题中。

在您的主题中创建一个 bbpress 文件夹。

wp-content/themes/%yourtheme%/bbpress

其中 %yourtheme% 是您的主题名称

然后导航到

wp-content/plugins/bbpress/templates/default/bbpress/form-user-edit.php

并将此文件复制到您在上面创建的 bbpress 文件夹中

bbpress 现在将使用这个而不是默认值。

编辑这个新文件并取出第 33 到 45 行

即取出以下内容

<div>
            <label for="nickname"><?php _e( 'Nickname', 'bbpress' ); ?></label>
            <input type="text" name="nickname" id="nickname" value="<?php bbp_displayed_user_field( 'nickname', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />
        </div>
        <div>
            <label for="display_name"><?php _e( 'Display Name', 'bbpress' ) ?></label>
            <?php bbp_edit_user_display_name(); ?>
        </div>
        <?php do_action( 'bbp_user_edit_after_name' ); ?>

这将删除设置昵称和更改显示名称的功能。

19. 链接到一个随机的单个话题

这是一个非常漂亮的功能,允许用户通过单击链接浏览随机话题。

如果您启用了它,它会挂在主要主题之前,否则它还会创建一个名为 [ntwb-bbpress-random-single-topic] 的简码,允许您将其放入小工具或 WordPress 帖子中。

// bbPress - Random Single Topic
function ntwb_bbpress_random_single_topic() {
    if ( bbp_has_topics( array( 'orderby' => 'rand', 'posts_per_page' => 1 ) ) ) {


        while ( bbp_topics() ) : bbp_the_topic();


            ?>
            <a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>">Random Topic</a>
            <?php


        endwhile;
    }
}
// Hook into action
add_action('bbp_template_before_lead_topic','ntwb_bbpress_random_single_topic');
// Add it as a shortcode [ntwb-bbpress-random-single-topic]
add_shortcode('ntwb-bbpress-random-single-topic', 'ntwb_bbpress_random_single_topic');

20. 重命名用户角色名称

此功能允许您重命名 bbPress 预定义的用户角色。

只需将 「我的自定义 *** 角色名称」 更改为您喜欢的内容即可。

add_filter( 'bbp_get_dynamic_roles', 'ntwb_bbpress_custom_role_names' );


function ntwb_bbpress_custom_role_names() {
    return array(


        // Keymaster
        bbp_get_keymaster_role() => array(
            'name'         => 'My Custom Keymaster Role Name',
            'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
        ),


        // Moderator
        bbp_get_moderator_role() => array(
            'name'         => 'My Custom Moderator Role Name',
            'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
        ),


        // Participant
        bbp_get_participant_role() => array(
            'name'         => 'My Custom Participant Role Name',
            'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
        ),


        // Spectator
        bbp_get_spectator_role() => array(
            'name'         => 'My Custom Spectator Role Name',
            'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
        ),


        // Blocked
        bbp_get_blocked_role() => array(
            'name'         => 'My Custom Blocked Role Name',
            'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
        )
    );
}

21. 在论坛索引后显示 5 个最近的话题

此功能在您的论坛索引后显示最新的 5 个话题。

// Add Recent Topics to BBPress
function recent_bbpress_topics() { { ?>
 <?php
 if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) )
 bbp_get_template_part( 'bbpress/loop', 'topics' );
 ?>
<?php }}
// Hook into action
add_action('bbp_template_after_forums_index','recent_bbpress_topics');

22. 仅显示 1 个修订日志话题和回复

使用此功能清理您的修订日志。

// Only return one entry for revision log otherwise it gets cluttered
function bbp_trim_revision_log( $r='' ) {
 $arr = array( end( $r ));
 reset( $r );


 return( $arr );
}


add_filter( 'bbp_get_reply_revisions', 'bbp_trim_revision_log', 20, 1 );
add_filter( 'bbp_get_topic_revisions', 'bbp_trim_revision_log', 20, 1 );

23. 显示 bbPress 论坛搜索无处不在

在单个论坛和单个话题上方显示论坛搜索,但不在 bbPress 个人资料上。

//display bbPress search form above sinle topics and forums
function rk_bbp_search_form(){


    if ( bbp_allow_search()) {
        ?>
        <div class="bbp-search-form">


            <?php bbp_get_template_part( 'form', 'search' ); ?>


        </div>
        <?php
    }
}


add_action( 'bbp_template_before_single_forum', 'rk_bbp_search_form' );
add_action( 'bbp_template_before_single_topic', 'rk_bbp_search_form' );

24. 显示 bbPress 主题的状态标签

这些功能中的每一个都将帮助您根据当前主题的状态添加特定的标签或图标。

在每个话题旁边显示粘性标签。

function rk_sticky_topics() {


   if ( bbp_is_topic_sticky() && !bbp_is_topic_closed() )
      echo '<span class="sticky">[Sticky]</span>';
}


add_action( 'bbp_theme_before_topic_title', 'rk_sticky_topics' );

在每个话题旁边显示封闭标签。

function rk_closed_topics() {


   if ( bbp_is_topic_closed() && !bbp_is_topic_sticky() )
      echo '<span class="closed">[Closed]</span>';
}


add_action( 'bbp_theme_before_topic_title', 'rk_closed_topics' );

如果该话题的回复超过 25 条,则显示热标签。
(您可以将 25 更改为任何您想要的)

function rk_hot_topics() {
   $reply_count = bbp_get_topic_reply_count();


   if ( $reply_count > 25 )
      echo '<span class="hot">[Hot]</span>';
}


add_action( 'bbp_theme_before_topic_title', 'rk_hot_topics' );

如果某个话题已关闭且有粘性,则显示 「公告」 标签。

function rk_announcement_topics() {


   if ( bbp_is_topic_sticky() && bbp_is_topic_closed() )
      echo '<span class="announcement">[Announcement]</span>';
}


add_action( 'bbp_theme_before_topic_title', 'rk_announcement_topics' );

创建话题后一小时内显示 「新」 标签。
将偏移量更改为您想要的任何值,但请确保数量以秒为单位。
例如 60*60*1 = 3600 seconds ,这是 1 小时的秒数。

function rk_new_topics() {
$offset = 60*60*1;


   if ( get_post_time() > date('U') - $offset )
      echo '<span class="new">[New]</span>';
}


add_action( 'bbp_theme_before_topic_title', 'rk_new_topics' );

您可以通过在图标字体 HTML 中添加以显示图标来输入图标。

无论您在哪里看到这个

echo '<span class="example">[Example]</span>';

您可以轻松地将其更改为此。
在这里,我使用了 Dashicons 图标字体集中的随机字体。

echo '<span class="example"><span class="dashicons dashicons-admin-post"></span>[Example]</span>';

如果您要使用基本的 HTML 插入图标的方式,您可以使用这个小 CSS 片段来设置它们的样式。

#bbpress-forums li.bbp-topic-title span.dashicons {
  float: left;
  margin-right: 5px;
}

您也可以仅使用 CSS 在话题标题之前或之后插入自定义图标字体。

这是来自该站点的 Dashicons 示例。

此 CSS 代码在置顶帖之前的话题图标之前显示置顶图标。

ul.sticky 和 ​​ul.super-sticky 都是该话题的帖子类,您可以利用和自定义更多帖子类。

#bbpress-forums ul.sticky li.bbp-topic-title a.bbp-topic-permalink:before,
#bbpress-forums ul.super-sticky li.bbp-topic-title a.bbp-topic-permalink:before {
  font: normal 16px/1 'dashicons';
  content: '\f450';
  margin-right: 5px;
  float: left;
  padding-top: 3px;
  color: #bb0;
}

25. 限制用户访问 WordPress 后端

添加此 PHP 代码片段以仅允许只能编辑帖子的用户访问 WordPress 后端。

/**
 * Redirect back to homepage and not allow access to
 * WP backend for Subscribers.
 */
function rkk_redirect_admin(){
    if ( ! current_user_can( 'edit_posts' ) ){
        wp_redirect( site_url() );
        exit;
    }
}
add_action( 'admin_init', 'rkk_redirect_admin' );

您可能还想为参与者禁用 WordPress 工具栏。

/**
 * Disable toolbar on the frontend of your website
 * for subscribers.
 */
function rkk_disable_admin_bar() {
    if( ! current_user_can('edit_posts') )
        add_filter('show_admin_bar', '__return_false');
}
add_action( 'after_setup_theme', 'rkk_disable_admin_bar' );

您也可以安装 WP Admin No Show 来执行此类操作。

26. 创建一个 bbPress 特定的侧边栏

没有插件

注册您的新侧边栏

将此添加到您的子主题 functions.php 文件中

function rkk_widgets_init() {


    register_sidebar( array(
        'name' => __( 'bbPress Sidebar', 'rkk' ),
        'id' => 'bbp-sidebar',
        'description' => __( 'A sidebar that only appears on bbPress pages', 'rkk' ),
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    }


add_action( 'widgets_init', 'rkk_widgets_init' );

现在在您的子主题中编辑您的 sidebar.php 文件,并选择仅在 bbPress 页面上用 bbPress 侧边栏替换的侧边栏。

此示例使用的是直接来自话题 25 的代码。我们使用条件 is_bbPress 在 bbPress 页面上显示我们想要的侧边栏,并使用!is_bbpress 在 bbPress 页面上不显示我们想要替换的侧边栏。

<?php if ( is_active_sidebar( 'sidebar-1' ) && !is_bbpress() ) : ?>


        <div id="widget-area" class="widget-area" role="complementary">
        <?php dynamic_sidebar( 'sidebar-1' ); ?>
        </div><!-- .widget-area -->


<?php elseif ( is_active_sidebar( 'bbp-sidebar' ) && is_bbpress() ) : ?>


    <div id="secondary" class="widget-area" role="complementary">
    <?php dynamic_sidebar( 'bbp-sidebar' ); ?>
    </div><!-- .widget-area -->


<?php endif; ?>

现在转到仪表盘> 外观> 小工具,现在您将看到一个名为 「bbPress Sidebar」 的新侧边栏。

添加 bbPress 小工具后,它应该看起来像这样。

论坛1

带插件

使用以下任何插件都可以获得特定于 bbPress 的侧边栏。如果您认为您发现的内容不够好,我相信还有更多插件可以执行此类功能。

限制小工具

小工具逻辑

bbPress WP 调整

27. 登录后自定义重定向

要更改用户登录后重定向到的页面,有像 Peter's Login Redirect 这样的 WordPress 插件可以处理重定向,或者您可以使用和自定义此 php 代码片段来实现相同的功能。

下面的 PHP 代码片段会将具有 Admin 用户角色的用户重定向到 WordPress 后端,并将其他任何人重定向到您网站的首页。

/**
* WordPress function for redirecting users on login based on user role
*/
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if( $user->has_cap( 'administrator' ) ) {
$url = admin_url();
} else {
$url = home_url();
}
}
return $url;
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );

Official Logos and Icons

Official Logos and Icons

Official Logos and Icons
Codex Home → Official Logos and Icons
Transparent PNG:
bbPress – Logo Large 1259px x 363px

bbPress – Logo 2x 416px x 130px

bbPress – Logo 208px x 65px

Dashicons Icons:

bbPress Logo: content: "f477"; – class="dashicons dashicons-bbpress-logo"
Forums/Hive: content: "f449"; – class="dashicons dashicons-bbpress-forum"
Topics/Honey: content: "f450"; – class="dashicons dashicons-bbpress-topic"
Replies/Bee: content: "f451"; – class="dashicons dashicons-bbpress-reply"
Note: The dashicons CSS classes will only work with WordPress 3.9 or newer.

Color:

bbPress Green #2d8e42

Step by step guide to setting up a bbPress forum – part 4

Step by step guide to setting up a bbPress forum – part 4

Step by step guide to setting up a bbPress forum – part 4
Codex Home → Step by step guide to setting up a bbPress forum – part 4
Using Actions
Actions and Filters add a powerful way that you can alter how bbPress (and of course WordPress) work.
For the newcomer to WordPress, they are also probably one of the hardest to find information on. This tutorial tries to demystify some of this area, and help newcomers code those changes that will make their site work how they wish.
This section deals with actions.
1. Actions
These are things you can get wordpress to do at a particular point in the code.  So if you want to add something to an area, then an action is probably what you want.  WordPress and bbPress are full of actions points throughout the code.
So lets look at what one looks like, so that you can recognise it

They start with do_action and then each one has a unique action name.
This example above occurs in the bbPress code before the author avatar on a topic or reply
So if you wanted bbPress to say the words 「Posted by」 before the author details are shown in a topic or reply, you』d create some code that would 「hook」 to this action, and that』s what the code will do.
2. Finding the code
So where is the code that we need to look at?
This is of course the first issue with bbPress (as with any other part of WordPress – finding out what file needs to be altered.
All the critical template files (the most likely you』ll want to alter) are held in the folder
Wp-content/plugins/bbpress/tempaltes/default/bbpress
Whilst many of the names give a good clue to what they do, you』ll probably need to delve into a few before you find the one you want.
I plan to make a list of these templates and what they do if/when I work it out!
For the meantime, just look through, and you should find.
3. Where to add actions
In this tutorial, we』ll look the code you need to create, but obviously that code needs to go somewhere.  So where do we put it?
We add actions either to the functions file, or create them as a plugin.
Both methods have uses.
If you like using plugins, then they』re a good way to add changes, and work well if you have a number of sites, as the plugin is easily uploaded to each.  But they do require a bit more knowledge to code.  But google the subject and you』ll find lots of help on creating one.  Then just put the code into it, and upload to your site. If you want others to use your clever code, then a plugin is a definite.
The alternate is to use a functions file.  As you are now at the 「advanced」 stage of using WordPress, you should either be developing your own themes, or using a Childtheme to store the specifics.
If you still just have a main theme from someone else (eg a wordpress default theme, a free theme or a premium theme), then you should create a childtheme.  This simply uses the main theme, and the you can add your tweaks to the childtheme.  Then if the maintheme is updated, you tweaks in the childtheme are not overwritten.  For help on creating a childtheme  google 「child theme wordpress video」 and you』ll find lots of demonstrations.
If someone has built a site for you, it may already be a in a child theme, and again the video』s will let you see whether this is the case.
Within our childtheme, we』ll put a functions.php file, and the actions we set up will go in there.
4. Example of code we can alter
So to start to understand what we need to do, lets have a look at one of bbPress』s templates and see where these are used.
The file we』ll look at is called 「loop-single-reply.php」 and the dafault is held at
wp-content/plugins/bbpress/templates/default/bbpress/loop-single-reply.php
Loop single reply is the template that  is used by bbpress to display a topic and the replies associated with it – eg this page

If we start to look at this file we』ll find at around line 39 the following

'
', 'show_role' => false ) ); ?>

This part of the code displays the author details.
Line 1 – So the first things we see is an action an action for 『bbp_theme_before_reply_author_details』
Line 2 – This is followed by the bbp_reply_author link code which displays the author avatar, name, and role.
Line 3 – tests if the viewer is keymaster
Line 4 – if the viewer is keymaster, you can add some admin things to do here.
Line 5 – if the viewer is keymaster,displays the IP address of the author
Line 6 – is another action we can hook to after it has displayed this
Line 7 – ends the 「if admin..」 statement
5. Adding a simple action
So as stated above, if we hook to 『bbp_theme_before_reply_author_details』, we can add text or data at this point
So lets add 「posted by」 to the start of the author display area.
To do this we』ll simply hook to this action.
In effect we create a bit of code with

a name
what we want to hook it to, and
what we want it to do

The name must be unique, as other plugins, themes or indeed you could have actions that should be carried out at this point.
So this is what I coded :
//this function hooks to BBpress loop-single-reply.php and adds "posted by" before the author details
function robin_w_posted_by ()
 {
echo 'Posted by' ;
 }
add_action ('bbp_theme_before_reply_author_details', 'robin_w_posted_by') ;

So let』s pick this apart
Line 1 – starting 『//』 is a comment line. You may know today what this function does, but in a few months time, you may not, so comments are good to remind you !
Line 2 – This sets up a function and calls it  『robin_w_posted_by』.  Functions within your website must be unique, so adding your name at the start will make it highly unlikely that any WordPress, bbPress or any plugins you have will already have this name.
Line 3 – The actual function code is then contained in the {  } so this opens the function code area.
Line 4 – the function code – in this case it is a simple 『echo』 command
Line 5 – closes the code area
So that creates the function, but now you must hook it to the do_action command in the bbPress code, that is tell WordPress where to implement it.
Line 6 – The final 『add_action』 command tells WordPress to add an action to 『bbp_theme_before_reply_author_details』 called 『robin_w_posted_by』 – the function we』ve just created.  And that』s it!
so

becomes

6. Adding an Action – further example
This example adds a post count to the author area, using the do_action( 『bbp_theme_after_reply_author_details』 ) action hook
//this function hooks to BBpress loop-single-reply.php and adds the post count to the reply display
function robin_w_display_count ()
{
$post_count = bbp_get_user_post_count( bbp_get_reply_author_id( $reply_id )) ;
echo "
Total posts : " ;
echo $post_count ;
echo "" ;
}
add_action ('bbp_theme_after_reply_author_details', 'robin_w_display_count') ;

Very similar to the first example, but here we set a variable called $post_count to the count and then use this to display the count.
The result: