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 );
}
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 code will close the topic on 100 replies, so unless you tested with creating the 100th reply, then it would not work. Did you do this ?
I changed that number from 100 to 10 and posted over 11 replies.
if ($count == 100) bbp_close_topic( $topic_id );
↓
if ($count == 10) bbp_close_topic( $topic_id );
However, it was not closed.
Thanks.
ok, I cannot say why it is not working, it works in my test site
I presume this code is going into you child theme’s function’s file – sorry but I do not know how technical you are, so I ask the obvious questions !
you could try >9 and see if that works !
Hi,
Unfortunately, it didn’t work out.
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 >9) bbp_close_topic( $topic_id );
}
If you have further information, please let me know.
Thanks.
ok, sorry I can’t say why it is not working on your site
Thank you for helping me:)