Hi, Thanks for the reply.
But that code did not close.
So, I wrote the following code for now.
<p id="replies_count"><?php bbp_topic_reply_count(); ?></p>
<script>
(function($){
var replies_count = $('#replies_count').text();
if( replies_count >= 100 ){
$('.bbp-reply-to-link').css('display','none');
}
})(jQuery);
</script>
However, It’s incomplete just because it is hidden, so I would like to close it as well.
Please let me know again if there is another code.
Thanks.
that would take a lot of code, beyond free help
add this to your functions file, it closes the topic when the 100th reply is posted
add_action( 'bbp_new_reply_post_extras', 'rew_close_topic' );
function rew_close_topic ($reply_id) {
// find out the topic_id
$topic_id = bbp_get_reply_topic_id ($reply_id) ;
$count = bbp_get_topic_reply_count ($topic_id) ;
if ($count == 100) bbp_close_topic( $topic_id );
}
No idea from your post of what code you are trying.
bbp_has_replies is the function you need for the loop
the default is false, so it would do nothing – you should be using
$show_lead[] = 'true';
then it will use the template it talks about and you can style it
Thanks again, Robin!
I’ve successfully used the code above to modify the templates. Woo!
However, one question / comment:
The code you’ve provided for bbp_show_lead_topic doesn’t seem to do anything for me.
I’ve tried:
function custom_bbp_show_lead_topic( $show_lead ) {
$show_lead[] = 'false'; // The code as shown on https://codex.bbpress.org/bbp_show_lead_topic/
$show_lead[] = false; // No quotation marks around 'false'
$show_lead = false; // no array [] used on $show_lead, no quotation;
$show_lead = 'false' // no array, with quotation
return $show_lead;
}
And none of these seemed to change how the lead topic was displayed.
But, I’ve figured out the templates and I’m getting the results I was hoping for.
Thanks again.
the function that bbpress uses is in
includes/common/functions.php
line 1055 starts the function, and lines 1150 to 1153 are the offending ones which stop it being sent to the author
I’d suggest you unhook that function and then hook your own
so in your child theme functions file maybe have
remove_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 );
add_action ( 'bbp_new_reply' , 'rew_notify_topic_subscribers', 11,5 ) ;
and then copy the whole bbp_notify_topic_subscribers function to your functions file, rename it to ‘rew_notify_topic_subscribers’ and edit out the lines which stop it being sent to the author
do come back if anything isn’t clear, I’m assuming a level of knowledge you may not have, and quite happy to help further
Hi,
I’d like to restrict the reply to 100 cases, but is there a way?
For example, I want to make it .bbp-reply-to-link{display:none;} when comment becomes 100 or more.
However, since only 15 replies are displayed on one page, JS can not count comments on loading.
So, It’s best if you can do that with PHP settings…
What should I do?
Thanks.
Hi,
I used above code/plugin to add delete_topics in capabilities for participant and it doesn’t work.
Can you help me, how I allow users trash their own topics?
Thanks
yes, that is the default position, I’ll try and work out some code in the next few days.
If I have not come back in 3 days time, post again to remind me !
something is putting that code there, you will need to work out what
It could be a theme or plugin issue issue, so you’ll need to test to find out which
Themes
As a test switch to a default theme such as twentyfifteen, and see if this fixes.
Plugins
Deactivate all but bbpress and see if this fixes. if it does, re-enable one at a time to see which is causing the error.
Then come back
ok, sorry but you can only fault find by testing.
Only having a live site is not a good policy, suggest you invest time in creating a test site
Creating a Test Site
the function (1) can sit in your plugin
the template (2) can also be in your plugin, but yes, you’ll need some code to do this
in my style pack plugin I have a directory and sub directory called
templates/templates1 and in this I have a bbpress templates I have amended eg
wp-content/plugins/bbp-style-pack/templates/template1/loop-forums.php
then in my plugin code I have (you’ll need to amend BSP_PLUGIN_DIR to a suitable name for your plugin
if(!defined('BSP_PLUGIN_DIR'))
define('BSP_PLUGIN_DIR', dirname(__FILE__));
add_action( 'bbp_register_theme_packages', 'bsp_register_plugin_template1' );
function bsp_register_plugin_template1() {
bbp_register_template_stack( 'bsp_get_template1_path', 12 );
}
function bsp_get_template1_path() {
return BSP_PLUGIN_DIR . '/templates/templates1';
}
This loads all templates in that directory and registers them with bbpress
come back if that doesn’t work for you with your code
Thanks Robin. I previously played with bbp_show_lead_topic, and I couldn’t get it to work (which is why I posted my question above.) I guess I was missing step 2, which is the template.
Question: Do the steps you describe change if I’m developing a plugin, instead of a theme? If I’m correct, the following code should help me (correct?)
correct way to override bbpress templates
Hello,
I’d like to share my workaround to fix the following problem:
After importing all topics and posts and forums and users from my old WebsiteA, I couldn’t see any topics inside my forums on my new WebsiteB. The counts were correct, but I could only see sticky topics inside each forum, nothing else.
I tried the built-in fixing tools, but that was a BAD IDEA. It broke my site every time I tried it (blank page on front-end without any error). The only way to fix it was to restaure the whole database!
So I looked at the database and found that a simple info was missing. All topics were set with post_parent = 0, while the corresponding postmeta _bbp_forum_id field was set correctly.
All that was needed to do is to update this post_parent field by fetching this meta value.
Here’s my working SQL script (of course do NOT FORGET to save your database first…):
UPDATE 'wp_posts'
SET post_parent = (
SELECT meta_value
FROM 'wp_postmeta'
WHERE post_id=ID AND meta_key="_bbp_forum_id")
WHERE post_parent = 0;
I also want to point something VERY annoying when using the WP importer. WordPress asked me to match every single forum user from WebsiteA with the dropdown list of users from WebsiteB, which is very stupid since I had imported all the users. They were all identical.
It literally took me an hour to select every user on the dropdown menu…
The user IDs were the same on both websites!! Why not auto-selecting???????
I hope some dev will see this and fix it somehow, because it sounds like something quite easy to fix 😉
Have a nice day
Hi Robin, So sorry for late reply.
Yes, I still stuck on the issue. Hoping the topics of the certain forum (by forum ID) can automatically close after 30 minutes, even if it has updated during this period. I paste the original code of the plugin and I have tried to modify it but failed. I will appreciate your patience and help with this situation.
ok, so concentrating on a topic and it’s reply list and ignoring forums, you are saying that you would like
from clicking a topic in the forum list (a list of topics in the forum) you are taken to a page which displays
- the topic name
- some content/info but styled and controlled by you
- the replies as per normal
- the reply form
If so I suspect you need to do two things
1. use this piece of code in your functions file
bbp_show_lead_topic
2. amend content-single-topic-lead.php in your child theme’s bbpress directory.
by
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpress
where %your-theme-name% is the name of your theme
find
wp-content/plugins/bbpress/templates/default/bbpress/content-single-topic-lead.php
Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/content-single-topic-lead.phpbbPress will now use this template instead of the original and you can amend this
I have no idea how technical you are and whether that gives you enough to go ahead and fix, or if you need further help – let me know
I would only expect keymasters to see this – can you confirm that a user with participant access is seeing this, and say where it is appearing – ie within the forums list, the topic list in a single forum, a page with shortcode etc.
Hi Robin W, thank you for answer. My bbpress site some areas are broken in mobile. You can look screenshot or my forum page: notdefteri.net/forum Is there an add-on or code for %100 mobile compliance? thank you
https://ibb.co/bAxWgz
Thanks for the reply… but I think looking at the theme files only confused me more. (Sorry!)
I’ve taken a look at templates/loop-replies.php that’s built-into the plugin, which (if I understand correctly) is what is used when a user is viewing a topic’s page (in other words http://domain.com/forum/topic/awesomness/). I’m kind of confused as to how it works – near the bottom of this template, it calls another template using bbp_get_template_part( 'loop', 'single-reply' ); – and it does this whether it’s the topic’s content or a reply to the topic.
So, I’m uncertain if I need to modify the WP_Query (or where), or if I should modify the template.
I just noticed that this website, bbpress.org, does something similar to what I’m looking for. (Except, I’d remove the avatar and date.)
So, how does that work? I noticed that this site’s theme is called BB’s Parent, but that doesn’t seem to be available to the public (so I can’t check its code 🙁 )
Hello Support,
I am not able to see the reply form for my WP users(as subscriber) who are logged in on website.
I have checked the code of “form-reply.php” and it is saying in starting that <?php if ( bbp_current_user_can_access_create_reply_form() ) : ?>
My issue is even I have assign all of my user who’s role “subscriber” to “keymaster” as well, but when I go to my website front end and try to login as user it works but when I go to list of topics it says “You must be logged in to reply to this topic.”
Please help
I’ve been having a similar issue (WordPress 4.9.8, bbpress 2.5.14, no Buddypress). Forum users with the Participant role were able to view the existence of private forums but not any of the actual topics inside them. I tried creating a new role with read_private_topics enabled as well and assigning it to them, but to no avail. The only thing that seemed to fix it is what @kingstringy mentioned above:
The only thing that repairs the issue is switching each forum to public, saving the forum, then returning the forum to private status and saving again. Bulk edit doesn’t work — only updating each forum individually.
After having done that, users with the standard Participant role are able to see private forums again, with no other customization or plugins needed.
I wonder if there is a bug with the Bulk Actions dropdown in the Forums admin page? That’s what I used to set them to Private originally. Maybe it failed to update something that it needed to, whereas setting the visibility to Private on each forum individually succeeded.
I noticed that there is no space before the word “days” in your line here
if ( $last_active < strtotime( '-' . $this->old_topic_age_setting() . 'days' ) ) :
This means that it’ll result in “-1days”, and every example I’ve seen for strtotime() has a space before the word “days”, so ‘-1 days’.
I haven’t used strtotime() a lot so I’m not totally sure, but that one space could make a difference.