Found solutions in an other forum, just to add in the functions.php:
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
} elseif ( is_tax() ) { //for custom post types
$title = sprintf( __( '%1$s' ), single_term_title( '', false ) );
} elseif (is_post_type_archive()) {
$title = post_type_archive_title( '', false );
}
return $title;
});
add_filter( 'bbp_get_form_reply_content', function( string $reply_content ) {
if ( isset( $_GET['bbp_reply_to'] ) && (int) $_GET['bbp_reply_to'] ) {
$display_name = get_the_author_meta( 'display_name', get_post_field( 'post_author', (int) $_GET['bbp_reply_to'] ) );
return '@' . $display_name . PHP_EOL . $reply_content;
}
return $reply_content;
});
You should add this code in “functions.php”.
Hello Regnalf,
I’m happy to report that your fix worked. I had to apply the new class to all the previous CSS code, but it did the trick!!!
This is truly got the time to appreciate firsthand php notions such hook and filters, etc and see them at work. It was neat to be able to fine-tune the bbpress-index class vs bbpress and target one vs all parts of the site. I’m grateful.
Pushing my luck a bit further and modeling your code above and another post I saw elsewhere, I was hoping to get a bit more granular in the way I applied my css to parts of the forum, so I tried this bit of code below to target individual topic pages (or replies?)
but it didn’t work. If it’s not too much to ask, whenever it’s convenient for you or anyone, could you tell me if this code below somewhat does what you just provided me.
function my_topic_class($classes) {
$classes[] = 'herman-topic-class';
return $classes;
}
add_filter( 'bbp_get_topic_class','my_topic_class' );
Nowhere, when viewing the topic page or thread did I see the new class ‘herman-topic-class’ in the Inspect Element utility. With your code, the bbpress and bbpress-index appeared.
thanks in advance for all the support.
H
I don’t know how you excactly you want to style the forum index page, but i found out that the index page doesn’t have the bbpress class included in the body tag like the sub pages. So i had the problem too that i couldn’t style the index page.
Here is my code i use to add this class, and others, to the body tag for the index page. Then you can style the index page with css.
add_filter( 'body_class', 'bbpress_add_body_class' );
function bbpress_add_body_class( $classes )
{
global $wp;
$bbpress_index = get_option ('_bbp_root_slug');
$bbpress_search = get_option ('_bbp_search_slug');
if (strpos($wp->request, $bbpress_index) !== false)
{
$classes[] = "bbpress";
}
if ($wp->request == $bbpress_index)
{
$classes[] = "bbpress-index";
}
if (strpos($wp->request, $bbpress_index . "/" . $bbpress_search) !== false)
{
$classes[] = "bbpress-search";
}
return $classes;
}
Hi Robin,
Thanks as always for your assistance.
Starting with the last question, I have BuddyPress installed but not activated…
As for the slug, I’ve now ditched the underscore thing and went with /lab for the shortcode page, and in settings, /forums for the root and /forum for the forum. My permalinks are back to %postname%. This current setting guarantees that all my styles are displayed properly when accessing the page with the bbp-forum-index shortcode.
If I visit the /lab page, it’s all good until I clicked on a specific forum. Then the /lab is lost to acquire /forums (declared the settings) and thus display a 404 error page since there’s no page with that /forums/forum/topic, etc.
When I switch to having the shortcode page slug and settings slug be the same, no 404 error message, but all customizations vanish.
I’ve read some other post talking of templates not being properly referenced and honestly, so I created a bbpress folder in my childtheme. Since I’m not sure which templates/file to copy inside the newly-created BBPRESS there, I tried copying all php files included in the default template folder inside the BBPress plugin, and it didn’t go to well, so I removed them.
Still not sure where else to look. 🙁
I appreciate other pointers you or other bbpress-ers might have.
Best,
H
Hello,
I don’t know if anyone here was able to resolve their issue, but mine is quite similar to the OP.
Scenario: Created a forum with the shortcode [bbp-forum-index] on page with having slug /custom_forum to output index page. Used css to style the page (no theme builder).. In the forum settings, the root is set to /forums. When visiting /custom_forum, all the style appears great.
However, if I head to Settings–> Forums to change the root from /forums to /custom_forum (where my shortcode is placed), I lose all the styling.
I reset the permalinks as suggested above to no avail. I know it’s been over 7 years this has been reported and I hope anyone out who’s found a solution can assist me. Thanks in advance for your support.
This is theme related, but if you can give me a link to a live example, I might be able to give you some code
Hmm. The code given in your first reply doesn’t seem to work. Subscribers/Participants still get the error message, “Error: Duplicate reply detected; it looks as though you’ve already said that.”
I have removed all other php and disabled plugins.
Ideas?
line 309 of includes/replies/functions calls a function calledbbp_check_for_duplicate within the bbp_new_reply_handler function
That function checks for duplicates and is in includes/common/functions line 663
within that function line 676 for a check
if ( user_can( (int) $r['post_author'], 'throttle' ) ) {
return true;
}
so allowing participants to throttle allows duplicates
It is a bit of a fudge, but should work !!
Thanks!
It seems that for an admin/moderator user this works. But for a regular subscriber/participant it still blocks duplicates.
I kind of understand what the code is doing but not enough to understand why it’s not working. It doesn’t seem to be saying what role is allowed to bypass. Was I supposed to do something with this:
the easiest way to do this is to allow participant to ‘throttle’
I don’t see a setting for that. Could you explain more what I should do to allow participants to throttle?
the easiest way to do this is to allow participant to ‘throttle’ – this then lets them bypass this check
so the code (untested) should be :
add_filter( 'bbp_get_caps_for_role', 'rew_throttle_bypass', 10, 2);
function rew_throttle_bypass ($caps, $role) {
if ($role == bbp_get_participant_role() ) {
$caps['throttle'] = true ;
}
return $caps ;
}
ut this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
Is there a way to disable the “Duplicate reply detected” error checking? My forum will mostly be people uploading audio attachments and they may very well just say the same thing each time they post. But in the short term it’s a bother to my testers since they can’t just write “test” each time.
I know that the error code is in \wp-content\plugins\bbpress\includes\common\functions.php
I’m guessing there is some way to filter the bbp_check_for_duplicate function, but I don’t know enough php to do that.
I’ve seen some others post this question in the past but didn’t see answers.
(BTW, I posted this question a few hours ago but it got marked as spam. Not sure why. I included some code in it but have removed it in this one. Hope it’s ok to repost.)
That will get you to lots of bits of code which are usually around what you are trying to find
I’ll give it a go, thanks!
I heard back and GD bbPress Attachments doesn’t have anything I can hook into, so i will just have to increase the priority number.
Thanks for your help
bbpress is very large, and finding the right bit of code not easy !!
have you heard of notepadd++ ?
Google it and install it.
Then download bbpress 2.6 to your PC and unzip it.
Then when you are looking in your browser at bbpress, you’ll usually find a class or ID wrapped around the code you want to change.
In Notepad++ do ‘search>find in files’ and search the class ot ID name in the bbpress directory you created.
That will get you to lots of bits of code which are usually around what you are trying to find
I do this a lot !!
quite a few bbpress additional plugins authors use ‘bbp’ as a prefix to indicate the the class/code is bbpress related.
Oh, that’s really good to know. Thank you.
I was able to find the event (is that the proper name for it??) bbp_get_reply_content and that allowed me to filter the reply content but not the attachment area. Then I changed the priority of the filter to 1000 and I was able to achieve my intended outcome. What I don’t know is if this is good coding practice or not. I thought I read somewhere that super high priorities are not a good idea. In any case, I did post to the plugin company’s forum to see if there is a better/more specific event to filter. I’ll report back what I learn.
But a general bbPress question if I may. How is one supposed to learn about events such as bbp_get_reply_content? I did a search in the bbPress documentation and there are no results. I was only able to find it by discecting the GD bbPress Attachments code. I did come across a site called hookr.io. Is that the best resource?
I recently spent several hours trying to fix an issue and when I posted all I got back was ‘already fixed elsewhere’
🙁 that’s a bummer.
I really appreciate your work supporting the forum and bbPress. Open Source software is nothing without people who dedicate time to support users. Thank you and all who help here.
on 2. – no problem 🙂 🙂 🙂 I recently spent several hours trying to fix an issue and when I posted all I got back was ‘already fixed elsewhere’ as the response, so this is a current hot button for me – apologies if I sounded irritable 🙂
on your filter – quite a few bbpress additional plugins authors use ‘bbp’ as a prefix to indicate the the class/code is bbpress related. bbpress itself does not have a class of bbp-attachments so suspect this is attachments plugin related.
I would try Milan as a first port of call, he is usually helpful, but do come back if he can’t help.
Thanks again for such a quick reply!
1. since this relates to bbpress attachments plugin specifically, it would be better to ask there – Milan should be able to help
So I just now tested putting the code (in this case a link) I’m trying to filter in the body of a reply in addition to having it be in the attachment (hadn’t thought about trying that before) but before I posted I saw <div class="bbp-attachments"> in the page source and so figured that attachments were something in core bbP, not just the GD bbPress Attachments plugin.
And the result of that test now is that the link in the body of the reply is also not filtered. So I think I’m back to this being a bbP thing and not a GD bbPress Attachments.
I notice that you also asked about empty replies in that forum as well as this forum where I gave you a fix – it is very frustrating for plugin authors and helpers when they spend time on an issue only to find that the original poster has already fixed it
I totally get that! At the time, I had no idea what the response rate was going to be. Sometimes communities/companies reply within the hour (as you did, thanks!!) or if they will take weeks. So not being sure which was causing the problem, I did post in both places. Please forgive me. I was surprised that both places replied so quickly.
It would be polite to do this
I did! Within minutes of seeing his response. Wasn’t it visible to you? Should I have linked back to the forum as well? I’m happy to, I just thought the code was enough. I totally know the frustration of support posts that end with “Oh, never mind, I fixed it.” and no solution.
Anyway, since I now know that my filter also doesn’t catch things in the body of the reply either (and I would like it to) are we back to this being a bbP thing? Are there other troubleshooting things I’m missing? I have disabled all other plugins and tried a default theme.
Hello!
I’m trying to filter links that appear in responses. More specifically, they are links that appear in attachments that have been added through GD bbPress Attachments if that matters. I’m fairly sure the code works because it can filter in the content of a page just fine. Here is the code:
add_filter( 'the_content', 'myprefix_use_audio_short_tag' );
function myprefix_use_audio_short_tag( $content ) {
$reg = "#<a .+ href=\"(.+?\.mp3)\".+?</a>#";
$content = preg_replace($reg, "[audio mp3='$1' class='asset-audio' title='']", $content);
return $content;
}
I’m guessing that it shouldn’t be the_content, but I am really working beyond my actual understanding of WordPress. I don’t know if I should be putting a theme file name there or if there is some equivalent to the_content that targets responses in bbP.
Feel free to criticize my regex as well. I’ve actually never used regex in WP/php before.
BTW, my code has been adapted from here: https://stackoverflow.com/questions/55814952/how-to-generate-audio-shortcode-when-theres-an-mp3-in-a-link-tag-in-wordpress
WP 5.8
bbP 2.6.6
ok, so in the example above, what does $value2 equal
$value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
and what is the full url that you want?
I’m sorry to ask you many questions.
I asked a question before, but I haven’t solved it yet.
so I really need a code to solve it.
I want to add “http://www.example.com/wp-content/uploads/○○” to the image.
This is the code I made from Mr.Robin, but i haven’t been able to add the url to the image and display it yet.
I’ve been studying for 2 days, and expecting that using <?php $upload_dir = wp_upload_dir(); ?>will come closer to solution, but…


add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields');
function bbp_extra_fields() {
$value11 = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field2', true);
echo '<label for="bbp_extra_field2">pic</label><br>';
echo "<input type='file' name='bbp_extra_field2' accept='.jpg,.jpeg,.png,.gif' value='".$value11."'>";
}
add_action ( 'bbp_new_topic', 'bbp_save_extra_fields', 10, 1 );
add_action ( 'bbp_edit_topic', 'bbp_save_extra_fields', 10, 1 );
function bbp_save_extra_fields($topic_id=0) {
if (isset($_POST) && $_POST['bbp_extra_field2']!='')
update_post_meta( $topic_id, 'bbp_extra_field2',$_POST['bbp_extra_field2'] );
}
add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields');
function bbp_show_extra_fields() {
$topic_id = bbp_get_topic_id();
$value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
$img = '<img src=".$value2.">' ;
echo "pic: ".$value2."<br>";
echo "picture:".$img."<br>";
}
I tried your code but it created a fatal issue on the site..
ok, can you post the exact code you used, and that you put this in your child theme functions file
Hello Guys,
I’ve been wandering on the forum for quite some hours and even though the question has been raised many times, there don’t seem to have a proper answer so far.
When you enter your username / email within the lost password form, the only thing happening is that the page refreshes with an argument: https://site.com/page/?checkemail=confirm
It’s a bit confusing for the user. Has anyone found a way to either return a success/ failure message or at least redirecting to another page?
(I’ve tried some function.php codes, 301 redirect and bbp-style-pack.4.8.9)
Many thanks in advance for your help,
georges
Hello there,
I know that this thread is quiet old but I got the same problem.
There is no way for the user to know if the lost password request has been sent.
I tried your code but it created a fatal issue on the site..
Does anyone of you found a solution / alternative to this problem?
Many thanks in advance for your help.
georges
Layout and functionality – Examples you can use
In #16 the code says this:
//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');
But I believe it should be:
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');
The first code causes the html to display on the front end.
there should be an error message at the top saying
Your reply cannot be empty.
but the other plugin may be affecting this.
the quickest way to correct this is to create some content if it is blank.
This filter (untested) will deal with empty content and add a space character.
add_filter ('bbp_new_reply_pre_content' , 'rew_allow_blank_content') ;
function rew_allow_blank_content ($reply_content) {
if ( empty( $reply_content ) ) {
$reply_content = ' ' ;
}
return $reply_content ;
}
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
Code Snippets
I have initially set it to change empty content to a single space character ie
$reply_content = ' ' ;
however later checking by WordPress may delete this, so it may need some actual text – maybe like
$reply_content = 'this reply is has no text' ;