Hey guys,
I'm trying to create a Scheduled Task for recount basic member stats (Total members/Latest Member). The actual task has been created thanks to Arantor's tutorial, however the code for the task itself doesn't work. (Mainly because I'm no programmer :P)
I thought if I stole the code from ManageMaintenance for recounting the data it would work, however sadly it doesn't :(
// Recount total number of members.
function scheduled_recount()
{
global $sourcedir;
// Update all the basic statistics.
updateStats('member');
// Finally, update the latest event times.
require_once($sourcedir . '/ScheduledTasks.php');
CalculateNextTrigger();
}
Perhaps a real programmer could shed some light on how this can be done :)
P.S: The reason I'm doing this is because I have shared forums, and if a member registered at one, it doesn't update the others with the new member count. Hence, this idea.
LainaaP.S: The reason I'm doing this is because I have shared forums, and if a member registered at one, it doesn't update the others with the new member count. Hence, this idea.
Wait, you did not tell me this.
updateStats('member'); only updates the count of the forum it is run on. Not the others. Either you'd have to use custom queries or edit the updateStats function.
That's why I was just going the Task running on all the forums every hour.
There are several things wrong with the above.
Firstly, you do not need to manually call the retriggering, just return true and SMF will deal with the rest for you.
Secondly, updateStats('member') really isn't the way to fix this. If they're all linked, add some code after registration to update that rather than having to run extra queries every hour. Push, not pull, the information.
Thanks for the advise.
I found this post (http://www.simplemachines.org/community/index.php?topic=16190.msg2564370#msg2564370) and changed it to work for 2.0 and it's working perfectly regardless of what forum the user registers at.
However I just realized I should unshare log_online, doesn't play well with action=who :)