Devcr3 (@dimitri333)

Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • @dimitri333

    Participant

    @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

    @dimitri333

    Participant

    @robin-w what do you think?

    @dimitri333

    Participant

    register_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

    @dimitri333

    Participant

    @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

Viewing 4 replies - 1 through 4 (of 4 total)