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' ;
ok, I should say that I am NOT a bppress author, I am just a user who tries to help others.
I am author of bbp private groups plugin, which would not help you directly as you want non logged in to see topics, but does mean that I spent a great deal of time locking down bbpress, and knowing where the code displays stuff.
so for instance my code will not stop searches, access via a users profile, direct entry of urls and many more.
so if your site needs to seriously hide replies to non logged in, then you would need to hire a very experienced dev. I am trying to retire, so desperately not trying to take on work !!
I haven’t looked at your solution, and with a smile, will not have time to do this.
Wow, oh wow, Robin! I don’t know what to say. The timing of it is just…wow
I thought you had given up on me. So thanks so much for getting back to me with this solution. I’ll try it too.
I do want to say, however, that in my desperation for a solution, I hired a “developer” on Fiverr to resolve it. Well, it ended quite disappointingly. That guy couldn’t do a single task from adding css to even bothering looking at the php function I posted here earlier. Wasted 2 days and he admitted he’s not familiar with WP. Wait what? We’re now in the Resolution Center as I’ve asked for a full refund.
So again in desperation, just before receiving your fix, here’s what I did myself with some clunky conditional Logged in/ Logged out css tweaks + the initial php code I posted (the one with all the replies still showing but with a generic message): Post before solution | working CSS solution using initial php function and the css I laboriously came up with.
/* adding replies message */
body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > div.loop-item--1 > div.bbp-reply-content {
border: 1px solid #ffa07a;
background: antiquewhite;
padding: 4px!important;
}
/* Remove content replies */
body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-content{
display:none;
}
/*Remove author replies except child 1 and 2 */
body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-author{
display:none;
}
/*Remove header replies for all but child 1 and 2 */
body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.loop-item--1 > div.bbp-reply-header {
display:none;
}
/*Remove headers except child (1 & 2) */
body:not(.logged-in) li.bbp-body > ul > li:not(:nth-child(1)):not(:nth-child(2)) > div.bbp-reply-header{
display:none;
}
/*Remove nested replies */
body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > ul > li:nth-child(n+1) > div.loop-item--1 > div.bbp-reply-content{
display:none;
}
/* Remove author part of nest replies */
body:not(.logged-in) li.bbp-body > ul > li:nth-child(2) > ul > li:nth-child(n+1) > div.loop-item--1 > div.bbp-reply-author{
display:none;
}
/*remove header of nested replies
body:not(.logged-in) #topic-67506-replies > li.bbp-body > ul > li:nth-child(2) > ul{
display:none;
}*/
body:not(.logged-in) li.bbp-body > ul > li > ul.bbp-threaded-replies{
display:none;
}
It’s quite ugly but did the job, to my own surprise. I was leaving my desk now, and signing off Gmail when I saw your reply. I will give a try and update you. Just a quick question, would you say then that with your fix, it’s still possible for someone to peek at the hidden replies if they know what they’re doing? It’s 2:19AM, i’m fried! So grateful for the assistance. I’ll let you know as soon as I place your solution in my child theme.
Take care, and ttyl.
H
This should do what you want
<?php
/**
* Replies Loop - Single Reply
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
?>
<?php
$reply_id = bbp_get_reply_id() ;
// first topic reply shouldn't be hiding
$rep_position = bbp_get_reply_position($reply_id);
// if user is not logged in and not the first post topic
if ( !is_user_logged_in() && $rep_position == 2 ) {
echo "<br/><strong>Replies only viewable for logged in users</strong>" ;
bbp_get_template_part( 'form', 'user-login' );
}
elseif ( !is_user_logged_in() && $rep_position > 2 ) {
//do nothing !!
}
//otherwsie use is logged in and/or this is reply 1 !
else {
?>
<div id="post-<?php bbp_reply_id(); ?>" class="bbp-reply-header">
<div class="bbp-meta">
<span class="bbp-reply-post-date"><?php bbp_reply_post_date(); ?></span>
<?php if ( bbp_is_single_user_replies() ) : ?>
<span class="bbp-header">
<?php esc_html_e( 'in reply to: ', 'bbpress' ); ?>
<a class="bbp-topic-permalink" href="<?php bbp_topic_permalink( bbp_get_reply_topic_id() ); ?>"><?php bbp_topic_title( bbp_get_reply_topic_id() ); ?></a>
</span>
<?php endif; ?>
<a href="<?php bbp_reply_url(); ?>" class="bbp-reply-permalink">#<?php bbp_reply_id(); ?></a>
<?php do_action( 'bbp_theme_before_reply_admin_links' ); ?>
<?php bbp_reply_admin_links(); ?>
<?php do_action( 'bbp_theme_after_reply_admin_links' ); ?>
</div><!-- .bbp-meta -->
</div><!-- #post-<?php bbp_reply_id(); ?> -->
<div <?php bbp_reply_class(); ?>>
<div class="bbp-reply-author">
<?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
<?php bbp_reply_author_link( array( 'show_role' => true ) ); ?>
<?php if ( current_user_can( 'moderate', bbp_get_reply_id() ) ) : ?>
<?php do_action( 'bbp_theme_before_reply_author_admin_details' ); ?>
<div class="bbp-reply-ip"><?php bbp_author_ip( bbp_get_reply_id() ); ?></div>
<?php do_action( 'bbp_theme_after_reply_author_admin_details' ); ?>
<?php endif; ?>
<?php do_action( 'bbp_theme_after_reply_author_details' ); ?>
</div><!-- .bbp-reply-author -->
<div class="bbp-reply-content">
<?php do_action( 'bbp_theme_before_reply_content' ); ?>
<?php bbp_reply_content(); ?>
<?php do_action( 'bbp_theme_after_reply_content' ); ?>
</div><!-- .bbp-reply-content -->
</div><!-- .reply -->
<!-- end of else!!!-->
<?php
}
?>
BUT be aware this is only hiding replies at this point – there are many ways to see replies in bbpress.
@maxlevel Element Pack is useless either. It is not clear how it works and its functionality is just to create and insert shortcode which you can do it by shortcodes provided by bbpress directly.
I search a whole week and didn’t find any solution. Did you find any possible workaround to solve this issue?
Thanks
as
<img src="http://www.kimberleygundogs.com/wp-content/uploads/2019/12/dog-jumping.jpg" alt="" />
gives you

I did give you the proper code – you need to link to the full url of an image ie a file that is an image file
Could you please give me the proper code? I really appreciate it.
ok, I’ll give it one more try, and then you are on your own!!
your code would produce
<img src="84396884_480x480.jpg">
which is not a valid url, so produces nothing.
you need a link which is a valid url to an image, so one where you see an image if you put the url into your browser
Thank you as always. Mr Robin.
I tried the code but it didn’t work.
so i would like to know again.
I have set up a third field for clarity.
↓this is my code↓
add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields');
function bbp_extra_fields() {
$value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field1', true);
echo '<label for="bbp_extra_field1">URL</label><br>';
echo "<input type='url' name='bbp_extra_field1' value='".$value."'>";
$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' 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_field1']!='')
update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field1'] );
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();
$value1 = get_post_meta( $topic_id, 'bbp_extra_field1', true);
$value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true);
$img1 = '<img src="'.$value2.'">' ;
echo "Field 1: ".$value1."<br>";
echo "Field 2: ".$value2."<br>";
echo "Field 3: ".$img1."<br>";
}

