Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I modify the plugin so that the topics are auto closed after 30 minutes


  • jimmy369
    Participant

    @jimmy369

    I hope that it is appropriate to ask this question here. (WordPress 4.9.8, bbPress 2.5.14, Theme:TwentyTen)
    I hope that one of my forums can automatically close the topics after 30 minutes.
    I read this discussion (https://bbpress.org/forums/topic/auto-close-topic-after-some-time-days/) and tried to modify it myself, but I failed.
    Later I found a plugin called BBP Close Old Topics (https://wordpress.org/plugins/bbp-close-old-topics/).
    I tried to modify it myself, but in the end it can only be automatically close the topics after one day.
    I guess… is this the problem with these code?

    // Get timestamp of last activity of the topic.
    		$last_active = strtotime( get_post_field( 'post_date', bbp_get_topic_last_active_id( $topic_id ) ) );
    
    		// Compare last active timestamp with defined time period.
    		if ( $last_active < strtotime( '-' . $this->old_topic_age_setting() . 'days' ) ) :

    Is there something missing here that the command can only catch D (day) and not catch i (minute)?

    I’m at my wits’ end with this issue……Thank you so much.

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

  • jd-fb
    Participant

    @jd-fb

    I noticed that there is no space before the word “days” in your line here
    if ( $last_active < strtotime( '-' . $this->old_topic_age_setting() . 'days' ) ) :

    This means that it’ll result in “-1days”, and every example I’ve seen for strtotime() has a space before the word “days”, so ‘-1 days’.

    I haven’t used strtotime() a lot so I’m not totally sure, but that one space could make a difference.


    Robin W
    Moderator

    @robin-w

    @jimmy369 I will get round to answering this – but weekend here and I am away.

    If I haven’t responded in 4 days time, then post a new entry reminding me, and I’ll work on it.


    jimmy369
    Participant

    @jimmy369

    Hi Robin, So sorry for late reply.

    Yes, I still stuck on the issue. Hoping the topics of the certain forum (by forum ID) can automatically close after 30 minutes, even if it has updated during this period. I paste the original code of the plugin and I have tried to modify it but failed. I will appreciate your patience and help with this situation.


    jimmy369
    Participant

    @jimmy369

    @robin-w

    Thank you Robin.

    I want the 30 minutes to be

    -from original topic creation.


    Robin W
    Moderator

    @robin-w

    ok, try this – I think it works all fine, but let me know

    what it does is check every 5 minutes that any topic posted over 1/2 hour is closed.

    It will close all existing topics that meet this criteria.

    A topic will therefore be closed 30-35 minutes after the original post date

    BbPress close topic automatically 1/2 hour after topic is posted


    jimmy369
    Participant

    @jimmy369

    @robin-w

    Thank you Robin. It’s working well.

    You are awesome!


    Robin W
    Moderator

    @robin-w

    great – thanks for letting me know – enjoyed coding it!

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