I’ve found this on github and modified it a bit.
//Close forum topics inactive for more than 30 days
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();
$last_active = strtotime( get_post_meta( $topic_id, '_bbp_last_active_time', true ) );
if ($last_active < strtotime( '-30 days') )
bbp_close_topic( $topic_id );
}
}
I’m using it on the support forum of our Business directory plugin.
Hope you can find it useful too.
Thx