MyBB Community Forums

Full Version: Possible to Schedule a Plugin Activation?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Wondering if it is possible to activate a specific plugin at a specific time and then disable it 24 hours later.

Would I make a .php file and then adding it to the task manager or something like that?

Thanks!
-iHydra
a custom plugin with a task could do that, otherwise its not really possible as-is. and tasks are NOT cron jobs, they do not run at specific times, they run the first time someone visits a forum page after the task time was expected to run.
the simplest method would be to edit the plugin itself

e.g. if the plugin only does something with hooks, you could wrap the add_hook calls in an if(TIME_NOW < endtime && TIME_NOW > starttime) {}.

Then you could activate it but it wouldn't actually do anything outside the specified time window.

With plugins that already modify things in their install/activate routine (such as template changes) it's more difficult, that's where you need a task or something that actually runs the activation routine.
@pavemen, thanks for clearing that up.

@frostschutz, alright, I'll look inside the plugin and see if it modifies any templates. If it does, I'll just do it manually. Thank you!

And to confirm, when I add " if(TIME_NOW < endtime && TIME_NOW > starttime) {}" ; it should be activated already correct?
yes, the plugin should be activate and have all the settings made. however, the wrapper he showed you is a one time deal. you need to edit it every time you want it to run as the endtime and start time are unix timestamps for a specific time of a specific day
The add_hooks (or the entire plugin code except the info/activate/install routines) should be enclosed in those { } - otherwise it's a no-op that doesn't do anything. (I assume you have a basic understanding of PHP if you're going for the edit approach).

There's a lot to be said for the simple and obvious solution: register an event in your phone / calendar / whatever and do it manually - who cares really if it's not 24 hours sharp, considering international visitors and time zones?
Yea, I'm just going to do it whenever I have the chance. Thanks for the help though.