Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved [How To?] Adding Newpoints into user pruning task
#1
Not Solved
Is it possible to include newpoints number into user pruning so it doesn't prun users which have more than X points?
Reply
#2
Not Solved
You will need to edit the task file or write a plugin for it (iirc tasks include hooks since 1.8).
Reply
#3
Not Solved
(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.
Reply
#4
Not Solved
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.
Reply
#5
Not Solved
(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 :/
Reply
#6
Not Solved
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))
Reply
#7
Not Solved
(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/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?
Reply
#8
Not Solved
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.
Reply
#9
Not Solved
(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?
Reply
#10
Not Solved
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.
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)