there’s no problem with using priorities, especially as you know what it is affecting, just keep in mind that if you add a further bbpress content realted plugin and it doesn’t do what you want it might be related to this
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 !!
I’m using BBpress, and I really want my users to be able to reply to each other with the quote of what they’re going to reply, how do I do this? (Example: The person says: “Hello” I want to answer this with the quote “Hello” in my post)
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.
ok, 2 things I would say
1. since this relates to bbpress attachments plugin specifically, it would be better to ask there – Milan should be able to help
2. On looking at the attachments support forum 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, and if you post in multiple places and get a fix from one, it is good to update the other places and maybe even post the solution there as well to help others. It would be polite to do this 🙂
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
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.
The embeded template is not loaded in any of the bbpress pages because of which on embeding bbpress page, it results in loading complete website inside iframe for embed.
Getting 404 response on forum archive page
I’m using an attachment plugin in bbPress. When someone uploads an attachment to a reply but does not put any text in the reply box (which is totally fine for this forum) and then clicks “Submit”, this is what happens:
– the reply does not post
– no error message is given
– the form resets
I’d like it if either
– the reply posted with only the attachment
– or there was an error message
– or the form didn’t reset (i.e. clicking the button did nothing)
As it is, it’s very confusing because there is no indication of failure. Someone would have to look for their reply to make sure it submitted. That’s not reliable.
Thanks for any help!
Dear admin and all of bbpress forum member. I have 1 question.
How to pin comment to top in topic?
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.
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.
Thank you for your reply @maxlevel
I did exactly the same. I’m not sure why it is not working. It may is related to my theme. I’m using Astra theme. I guess you used Hello them, which is for Elementor.
I hope there is a possible solution since I eager to use bbpress rather than other forum plugins.
I currently have a bbpress folder in my theme which contains all the theme of my forum. I have a page archive-forum.php which displays the forum page and a page content-single-forum.php which displays the topics. I would like to know how to create a different display for a forum. I would like to display the first forum with a content-single-forum-slug.php and the other forums with content-single-forum.php. I have tried all : content-single-forum-slug.php, single-forum-slug.php, content-single-slug.php, single-slug.php. I didn’t succeed so I think it’s not possible.
I have the exact same problem with Astra theme. It is very strange that Elementor and bbpress, two well-known plugins, can’t be integrated after these years. I hope there is a solution and also a working tutorial. There are many tutorials and plugins to connect buddypress and Elementor, but there is no even a single tutorial for bbpress and Elementor !
@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
Hello Robin,
Thanks for the tip. I checked section 3 of the documentation you suggested. I’ve found the loop-single-reply.php in my theme. I can certainly insert similar file in the child theme.
Now, thought I get the “what” of your answer, the “How” still eludes me. I’ve been staring at that file for an hour, and I’ve got no clue as to where to place the cursor and what to write if you showed me where to place that cursor in the file.
The code pasted above in my original post was copied and pasted as is in my Child Theme’s function.php, hoping that it would at least replace actual replies with the generic statement, which it did.
Will you be so kind as to look at the loop-single-reply.php file below and instruct me how to change the file so that I get the intend result across the forum (for anonymous users, removing/hiding all replies except the first one + original post, and with the 1st reply showing “generic statement + Login | Register” urls)?
<?php
/**
* Replies Loop - Single Reply
*
* @package bbPress
* @subpackage Theme
*/
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
?>
<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 -->
On a separate note, have you developed any BBpress plugin having an upload function not restricted to the media library / where files are retrieved from the user’s local machines directly?
Thanks in advance for your continued support.
H
HTTP status code received for the reference page is 404 and not 200. That will be considered bad for SEO as it is giving 404 response for page which has content to display. You can check the console also too see the status code
the problem is that you are changing the actual content box, so it will still display 20 boxes with author details and only blank the boxes.
you basically need to alter the bbpress template loop-single-reply.php to achieve what you want
see
Step by step guide to setting up a bbPress forum – part 3
section 3
if you mean you are getting 404 to https://bbpress.org/forums/page/2/ , the this is working fine as far as I can see