It is fairly common to have an action or set of actions that you would like to perform on a piece of content (or member) only after a certain amount of time has elapsed between particular events.
For example, you might want to:
- Close a topic automatically a certain amount of time after it was created.
- Move a topic to a different forum if it hasn’t been posted in for a certain amount of time.
- Send members a polite follow up email if they haven’t logged in for a specified period of time.
There is a simple pattern that you can use in all of these cases, which isn’t so obvious to those that are new to rules, but is very easy to implement once you understand how it works.
Schedule the future follow up action(s) as the event occurs, making sure to use a scheduling keyphrase unique to that follow-up.
Why does this work? It’s in the keyphrase. Let’s take a look at example #2 above. We want to move the topic if it hasn’t been posted in for 3 weeks. So what we do is to create an action to move the topic to the new location, and schedule that action for 3 weeks in the future instead of executing it immediately. This way each time a post is made in the topic, the move gets rescheduled.
It’s important to use a keyphrase that will be unique to that topic, so we must include a token in the keyphrase such as the topic id. It could look something like this: “Move topic [content:id] to graveyard”. Of course, the token that corresponds to the id of what you are trying to move will depend on the event that you are writing your rule for, so make sure to look at the tokens list to see which token corresponds to your content id.
But the concept is pretty simple. With every post, we assume that it is going to be the last post that happens… and we schedule the future action for the set amount of time in the future. If another person posts in the topic, we simply schedule the future action again which removes any previously scheduled follow up action with the same keyphrase, and sets in motion the new follow up action. This way the only follow up action that is in motion for the topic is the one which was scheduled after the last time the chosen event occured (in this case, it’s when a topic comment is posted).
If no qualified event happens within the timeframe between the last action and the follow up action which causes the follow up to be rescheduled, then the follow up action executes and the cycle ends.