MyBB Community Forums
[How To?] Adding Newpoints into user pruning task - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: 1.8 Support (https://community.mybb.com/forum-175.html)
+--- Forum: General Support (https://community.mybb.com/forum-176.html)
+--- Thread: [How To?] Adding Newpoints into user pruning task (/thread-221422.html)

Pages: 1 2


Adding Newpoints into user pruning task - codedude - 01-08-2019

Is it possible to include newpoints number into user pruning so it doesn't prun users which have more than X points?


RE: Adding Newpoints into user pruning task - Omar G. - 01-09-2019

You will need to edit the task file or write a plugin for it (iirc tasks include hooks since 1.8).


RE: Adding Newpoints into user pruning task - codedude - 01-09-2019

(01-09-2019, 08:00 AM)Omar G. Wrote: You will need to edit the task file or write a plugin for it (iirc tasks include hooks since 1.8).

Hm, then how about last time online? As it deletes all members with 0 posts regardless if they logged in today.


RE: Adding Newpoints into user pruning task - Omar G. - 01-10-2019

I check and there is no default setting for that. You will need a plugin or modify the task file as well. If you have issues editing the file please provide specific questions about such issues so we can provide better support.


RE: Adding Newpoints into user pruning task - codedude - 01-10-2019

(01-10-2019, 08:31 AM)Omar G. Wrote: I check and there is no default setting for that. You will need a plugin or modify the task file as well. If you have issues editing the file please provide specific questions about such issues so we can provide better support.

Well is there any easy way to include WHERE lastvisit < UNIX_TIMESTAMP('2018-01-01 00:00:00'); inside task log Toungue

I know how to do it via SQL, but not how to implement it in task :/


RE: Adding Newpoints into user pruning task - Omar G. - 01-11-2019

If you are writing a plugin or want to use the Hooks plugin to hook into the task system, here is the link to check the code.
https://github.com/mybb/mybb/blob/feature/inc/tasks/userpruning.php#L87

Ideally you would add your code before if(!empty($users)), filtering out those who meets your criteria. Something about the lines of:
if(!empty($users))
{
	$yesterday = TIME_NOW-86400;
	$uids= implode("','", $users);
	$users = array();
	$query = $db->simple_select("users", "uid", "lastvisit<'{$yesterday}' AND uid IN('{$uids}')");
	while($user = $db->fetch_array($query))
	{
		$users[$user['uid']] = $user['uid'];
	}
}

if(!empty($users))



RE: Adding Newpoints into user pruning task - codedude - 01-11-2019

(01-11-2019, 06:57 AM)Omar G. Wrote: If you are writing a plugin or want to use the Hooks plugin to hook into the task system, here is the link to check the code.
https://github.com/mybb/mybb/blob/feature/inc/tasks/userpruning.php#L87

Ideally you would add your code before if(!empty($users)), filtering out those who meets your criteria. Something about the lines of:
if(!empty($users))
{
	$yesterday = TIME_NOW-86400;
	$uids= implode("','", $users);
	$users = array();
	$query = $db->simple_select("users", "uid", "lastvisit<'{$yesterday}' AND uid IN('{$uids}')");
	while($user = $db->fetch_array($query))
	{
		$users[$user['uid']] = $user['uid'];
	}
}

if(!empty($users))

So now I need to include into userpruning.php new settings from ACP right?


RE: Adding Newpoints into user pruning task - Omar G. - 01-12-2019

The example code above is to be inserted directly into the /dir/inc/tasks/userpruning.php file. I can't guarantee it will work as I didn't test it.


RE: Adding Newpoints into user pruning task - codedude - 01-12-2019

(01-12-2019, 06:22 AM)Omar G. Wrote: The example code above is to be inserted directly into the /dir/inc/tasks/userpruning.php file. I can't guarantee it will work as I didn't test it.

Yeah id like to test it, but how to add input field into user pruning settings for $yesterday variable so i can setup a date which i want?


RE: Adding Newpoints into user pruning task - Omar G. - 01-12-2019

Add a new settings (MyBB has this feature by default), then change the following:
$yesterday = TIME_NOW-86400;

To:
$yesterday = TIME_NOW-(86400*(int)$mybb->settings['YOUR_IDENTIFIER']);

[Image: JsNSnvh.jpg]

I would create a custom group for custom settings myself.