Forum Replies Created
-
In reply to: Auto close topic after some time / days
@robin-w I installed the plugin, then I entered the code (mentioned above) in the code php section of the plugin .. in the end I saved. Now I wait 1 hour and see if it works
In reply to: Auto close topic after some time / days@robin-w what do you think?
In reply to: Auto close topic after some time / daysregister_activation_hook(FILE, ‘bbpress_topic_scheduler’);
add_action(‘bbpress_daily_event’, ‘bbpress_close_old_topics’);
function bbpress_topic_scheduler() {
wp_schedule_event(time(), ‘daily’, ‘bbpress_daily_event’);
}function bbpress_close_old_topics() {
// Auto close old topics
$topics_query = array(
‘author’ => 0,
‘show_stickies’ => false,
‘parent_forum’ => ‘any’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1
);
if ( bbp_has_topics( $topics_query ) )
while( bbp_topics() ) {
bbp_the_topic();
$topic_id = bbp_get_topic_id();
$topic_date = strtotime( get_post( $topic_id, ‘post_date’, true ) );
$forum_id = bbp_get_topic_forum_id($topic_id);
if ($topic_date < strtotime( ‘-5 hours’) && $forum_id == 9547 )
bbp_close_topic( $topic_id );
}
}Ps: code add to functions.php
In reply to: Auto close topic after some time / days@robin-w I’m trying to find an option to close topics (specific forum) after a some time, for example, after 1 days the topic was created. But this discussion is over 6 years old and doesn’t seem to work. I would simply like to close the various threads of a specific forum after 1 day (H 24) of creation. it can be done? TY