Delete Spam Users
Last modified by Denis Gervalle on 2021/03/18 11:28
![]() | Remove users who are considered spam accounts |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
Pass confirm=1 in the query string to the page to perform removal. Otherwise the snippet will simply list users that their first name equal to their last name.
{{velocity}}
Going to delete $xwiki.countDocuments(", BaseObject as obj, StringProperty as fname, StringProperty as lname where obj.className='XWiki.XWikiUsers' and obj.name=doc.fullName and fname.id.id=obj.id and fname.name='first_name' and lname.id.id=obj.id and lname.name='last_name' and fname.value = lname.value and fname.value = doc.name") users#if ($xcontext.action != 'get'):
#foreach($result in $xwiki.search("select distinct doc.fullName, fname.value from XWikiDocument as doc, BaseObject as obj, StringProperty as fname, StringProperty as lname where obj.className='XWiki.XWikiUsers' and obj.name=doc.fullName and fname.id.id=obj.id and fname.name='first_name' and lname.id.id=obj.id and lname.name='last_name' and fname.value = lname.value and fname.value = doc.name"))
#if ($request.confirm == "1")
#set ($userDoc = $xwiki.getDocument($result.get(0)))
$xwiki.getXWiki().deleteDocument($userDoc.getDocument(), false, $xcontext.context)
#set ($extraText = "- Deleted!")
#end
* $result.get(0) - $result.get(1) $!extraText
#end
#end
{{/velocity}}
Going to delete $xwiki.countDocuments(", BaseObject as obj, StringProperty as fname, StringProperty as lname where obj.className='XWiki.XWikiUsers' and obj.name=doc.fullName and fname.id.id=obj.id and fname.name='first_name' and lname.id.id=obj.id and lname.name='last_name' and fname.value = lname.value and fname.value = doc.name") users#if ($xcontext.action != 'get'):
#foreach($result in $xwiki.search("select distinct doc.fullName, fname.value from XWikiDocument as doc, BaseObject as obj, StringProperty as fname, StringProperty as lname where obj.className='XWiki.XWikiUsers' and obj.name=doc.fullName and fname.id.id=obj.id and fname.name='first_name' and lname.id.id=obj.id and lname.name='last_name' and fname.value = lname.value and fname.value = doc.name"))
#if ($request.confirm == "1")
#set ($userDoc = $xwiki.getDocument($result.get(0)))
$xwiki.getXWiki().deleteDocument($userDoc.getDocument(), false, $xcontext.context)
#set ($extraText = "- Deleted!")
#end
* $result.get(0) - $result.get(1) $!extraText
#end
#end
{{/velocity}}