MyBB Community Forums

Full Version: Adding Newpoints into user pruning task
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is it possible to include newpoints number into user pruning so it doesn't prun users which have more than X points?
You will need to edit the task file or write a plugin for it (iirc tasks include hooks since 1.8).
(2019-01-09, 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.
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.
(2019-01-10, 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 :/
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/featur...ng.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))
(2019-01-11, 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/featur...ng.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?
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.
(2019-01-12, 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?
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.
Pages: 1 2