Tasks? How to use?
(2019-06-19, 10:30 PM)itsmeJAY Wrote: Thank you for this detailed explanation. I still have the following questions: Does the name of the function in the task file have to be defined in the plugin or can I call the function as I like? 
As I said here:
(2019-06-19, 06:40 PM)Mipher Wrote: Every task is connected to a file in the inc/tasks directory, which name is specified in the field "Task File". In this file you will specify what to do when your task is performed inside a function named task_filename, where filename is obv the name of the file connected to the task.
So, the field "Task File" is the value with key file in the $new_task array that you define during your plugin installation. If you specify as value myplugin you need to create a file in the inc/tasks directory named myplugin.php with inside a function named task_myplugin. Since it is your first time, I advise you to create first the task from the task manager, then search your new task in the mybb_tasks table and finally copy your task specifications in the $new_task array.

(2019-06-19, 10:30 PM)itsmeJAY Wrote: And why we need the Parameter $task in 

function task_filename($task)? 

To add the tasklog or why?
In primis because the function is called by MyBB passing one argument: inc/functions_task.php#L90. But it will not give you any exception if you do not specify it, so, mainly yes, it is needed in order to call add_task_log() correctly. Also, keep in mind that $task contains all informations about your task, so it may return useful if you need to do any specific check (but I do not think you will need it for this).

Messages In This Thread
Tasks? How to use? - by itsmeJAY - 2019-06-18, 06:35 PM
RE: Tasks? How to use? - by Mipher - 2019-06-19, 06:40 PM
RE: Tasks? How to use? - by itsmeJAY - 2019-06-19, 10:30 PM
RE: Tasks? How to use? - by Mipher - 2019-06-20, 06:48 AM
RE: Tasks? How to use? - by itsmeJAY - 2019-06-20, 10:56 AM
RE: Tasks? How to use? - by gimbal - 2019-08-15, 04:46 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)