Jump to content

Recommended Posts

I have 100+ spam/Russian user accounts on a semi-test site. Is deleting them one by one the only option? Is there no way to select a whole page of spam user accounts and batch delete them?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Using the API you can also search on users instead of via pages with user template:

$users = $users->find('email=crap.hacker@mail.ru');
foreach($users as $u) { // don't use $user
	$u->delete();
}

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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)..

Share this post


Link to post
Share on other sites

Thanks flydev.

email*=@mail.ru was the first option I had tried, but it didn't work and the '@' produced a syntax error. 

~= didn't work either.

email%=mail.ru worked.- 'using slower SQL LIKE' according to the docs.

Share this post


Link to post
Share on other sites

adrian, with '... *=@ ...' I get 'Exception: SQLSTATE[42000]: Syntax error or access violation: 1064 syntax error, unexpected '@' (in /home/.../wire/core/PageFinder.php line 410)'

*=@ does work as expected with other fields, like 'name', so I'll ignore this issue for now...

Share this post


Link to post
Share on other sites

What version of PW, PHP, and MySQL are you running? Are you using MyISAM or INNODB tables?

Can you debug a few lines above where that error is being reported and let us know the content of $query

Share this post


Link to post
Share on other sites

Latest version of PW, PHP 5.6.30, Both MyISAM and InnoDB tables - is that normal/acceptable? Not sure how that happened.

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndZyk
      Hello,
      this maybe a simple question, but it bothers me for a while now:
      There used to be a warning, if two or more user try to edit the same page. But ever since AdminThemeUIkit I haven't seen it any more.
      Is this a bug or are there special circumstances under which the warning will be displayed?
      If I am logged-in in the same browser with one default and one privat window, I don't see this warning. But also different browsers on different machines in the same network don't see this warning.
      I was looking for the blog post on which this feature was announced, but couldn't find it anymore.
      We had the case, that two people were writing a text for the same page, but after person A saved the page first, the text of the person B was lost. I know we could have used ProDrafts for this case, but it shouldn't happen in the first place.
      I would appreciate some feedback. 😀
      Regards, Andreas
    • By SwimToWin
      I have a website that allows users to create their personal "website" (a page with sub-pages).
      Users shall be able to:
      Log in (frontend and/or admin), Edit "their" page(s) - I am using the "Page Edit Per User"-module (https://modules.processwire.com/modules/page-edit-per-user/) to grant access to the relevant pages Create child pages - possible? Users shall not be able to see other pages in the admin interface - "Admin Restrict Page Tree" may do the trick (https://modules.processwire.com/modules/admin-restrict-page-tree/)? Frontend editing shall be possible - I am considering "Fredi" (https://modules.processwire.com/modules/fredi/) for this. The challenge is that it takes a lot of modules and configuration.
      Is there a way to set this up that doesn't require a lot of configuration for each new user?
    • By benbyf
      Hello, having trouble getting PW to save my user or field in cron hook.
      It seems to report the same field info each time unchanged. It should be counting down in seconds.
      public function init() { // set to every30Seconds in settings $this->defaultInterval = $this->cron_check; // add hooks to CRON $this->addHookAfter("LazyCron::{$this->defaultInterval}", $this, 'checkUserSubscription'); } public function ___checkUserSubscription(HookEvent $e){ // seconds since last lazycron $seconds = $e->arguments[0]; $log = wire('log'); $field = $this->exclusiveRole; // users with specific role and field $users = $this->users->find("roles=$field"); foreach ($users as $user) { // get stored time $currentTime = $user->get($this->fieldName); // if time not null if($currentTime){ // evalute stored time minus time past $resultTime = intval($currentTime) - intval($seconds); $log->message("result ".$resultTime); // save user page $user->set($this->fieldName, $resultTime); $this->users->save($user); } } }  
    • By benbyf
      HELLO! having user Role issues.
      I've got a Role:  members and a template that is set to only allow view of Members and to redirect anyone else to / but id redircts Member users still currently, and only alows people to view the page if the template is set to view on the guest role also.
      Any help would be appreciated. I'm running  ProcessWire 3.0.62



    • By MrKing
      Hi,
      I am hoping to be able to use processwire for a charity with over 900 members and about 90 interest groups.
      One of the deciding factors (and there are many) is whether I would be able, as the admin, to add all my existing members, all the interest groups and all the group membership data programatically. As you might imagine, I would not want to do this by hand.
      I have written data upload scripts for a 'home brewed' experimental site but would much prefer to use processwire as the foundation of our site, if possible.
      Many thanks.
×
×
  • Create New...