Jump to content

Recommended Posts

  • 1 month later...

Thanks!

Where could I find user creation date? Lister only gives very imprecise 'three months ago' etc.

It would help if you could delete by role, like delete all 'guests' who are not 'member' or 'superuser'.

Are there any plans to build batch management of users into the core? Or make it easier?

How would batch deleting users by 'using the API' work?

Link to comment
Share on other sites

On 9/30/2017 at 3:37 PM, modifiedcontent said:

Thanks!

Where could I find user creation date? Lister only gives very imprecise 'three months ago' etc.

It would help if you could delete by role, like delete all 'guests' who are not 'member' or 'superuser'.

Are there any plans to build batch management of users into the core? Or make it easier?

How would batch deleting users by 'using the API' work?

If you outline exactly what you need maybe we can modify the Page Manipulator action, or create a new action designed specifically for deleting large numbers of users - I think this might be the best option. I am happy to build this if you mockup the interface.

  • Like 1
Link to comment
Share on other sites

Thanks adrianYour module has been very effective in deleting users; I wouldn't mess with it too much. The spam/hack accounts usually have some string in a name field in common that allows me to select them as batch.

It would be nice if some kind of batch delete was built in to Lister. And I am curious how 'using the API' would work for something like this; write a function and somehow add it to admin?

Thanks for the code suggestion fbg13I am mostly confused about where you would put this. In a template file? A setting page in the admin area? Would it have to  be a module?

And I have to figure out how to prevent bogus guest accounts. Could you make unverified guest accounts self-delete after 3 days?

Link to comment
Share on other sites

7 minutes ago, modifiedcontent said:

I am mostly confused about where you would put this

You can put it wherever you want. Depends on how you want to use it.

You can put in a template file and it will run when a page using that template is accessed, you can wrap it in a get variable and it will run only when that variable is set.

You can make a module and add a page in the admin and add a button that deletes the users.

This are just basic examples you can do a lot more than this.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

44 minutes ago, modifiedcontent said:

But how would you use the API for something like this?

You can also store it as a snippet in Tracy's Console panel - note the snippet name in the right sidebar. That way it will always be available and you won't have to remember it.

59d8f7a1778e9_ScreenShot2017-10-07at8_48_36AM.thumb.png.feb3ca17341b602be451bd8697a589b8.png

  • Like 1
Link to comment
Share on other sites

46 minutes ago, modifiedcontent said:

And I have to figure out how to prevent bogus guest accounts. Could you make unverified guest accounts self-delete after 3 days?

Take a look at: http://modules.processwire.com/modules/lazy-cron/

You can set that up to check at whatever time interval to make an API call to remove unverified accounts.

  • Like 2
Link to comment
Share on other sites

  • 2 months later...
1 hour ago, modifiedcontent said:

Still figuring out how to get wildcard like *@mail.ru to work...

Quote

The ~= and *= assume wildcard operations in selectors. They can be used for searching text, textarea and related fields. The ~= operator says to find all the words in the given copy (not necessary together),  and the *= says to find the given phrase in the copy. The ~= operator assumes wildcard matches with any of the words you provide, so a search for "apple" will also match "applesauce", "applet" and "apples", and likewise for any other words in the selector. The *= operator is more restrictive in that it's looking for your words in a specific order.

So something like the following will do the trick.

users = $users->find('email*=@mail.ru');
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

On 10/7/2017 at 11:27 AM, modifiedcontent said:

It would be nice if some kind of batch delete was built in to Lister.

ListerPro has actions, so you can filter down, select etc, then run actions on those results (such as delete)..

Link to comment
Share on other sites

4 hours ago, modifiedcontent said:

How do I do that 'debug a few line above where that error is being reported'? 

I think your best option would actually be to put:

print_r($stmt);

on the line before:

$database->execute($stmt);

You can post the output here, but you can also test it yourself (maybe in PHPMyAdmin) to see how the raw query goes. It might give us some idea of why it's failing.

Link to comment
Share on other sites

  • 1 year later...

Why doesn't this work?

$members = $pages->find("template=user");
foreach($members as $bogus) { // don't use $user
	if ( $bogus->firstname === $bogus->lastname ) {
		$bogus->delete();	
	}
}

I get this error:

Quote

Error: Exception: This page may not be deleted (in /.../wire/core/PagesEditor.php line 1017) ... etc.

If I echo $bogus->fullname, I get a nice list of spam accounts where the first and last name are the same. There has to be a way to let PW allow me to delete them.

I have also tried $users->delete( $bogus ) and $users->delete( $bogus, true ) and a few other variations, but keep getting the same error message.

Line 1017 is this:

if(!$this->isDeleteable($page)) throw new WireException

What makes a page not deletable? Any ideas?

I have a similar bit that deletes user accounts with numbers in the name fields:

$members = $pages->find("template=user");
foreach($members as $bogus) { 
	if ( preg_match('/[><\-0-9]/', $bogus->name ) ) {
		$users->delete( $bogus );
	}
}

That one works fine. What am I getting wrong with the other one?

Edit:

I think I figured it out. $firstname === $lastname would also be TRUE for two empty fields, so I guess PW has wisely made that not deleteable somewhere. So you have to check first if either field is set at all.

The following seems to work:

$members = $pages->find("template=user");
foreach($members as $bogus) { // don't use $user
	if ( $bogus->firstname && $bogus->firstname === $bogus->lastname ) {
		$users->delete( $bogus );
	}
}

Or still wrong?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...