Skip to:
Content
Pages
Categories
Search
Top
Bottom

Automatically "Close" posts after a certain number of days


  • George
    Member

    @georgegecewicz

    Hey all! We use bbPress to run our support forums over at Raygun.

    One issue we have is people re-posting in older topics.

    Is there a way to automatically “Close” open topics after a certain number of days, say 30 days?

    Thanks everyone!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I don’t think there is an easy way to do this, unfortunately, outside of writing a custom plugin.


    intimez
    Participant

    @intimez

    +1 for auto close

    inactive topic closed after [x] days


    Paolo
    Participant

    @paoltaia

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar