I would do it with a snippet so you can preview the results. This should get posts where the 'createdby' user doesn't exist:
$c = $modx->newQuery('modResource');
$c->where(array('id:>' => 9999); // Replace 9999 with the id 1 less than the oldest spam post
/* get all recent posts */
$docs = $modx->getCollection('modResource', $c);
$output = "<ul>\n";
foreach ($docs as $doc) {
$uid = $doc->get('createdby');
$user = $modx->getObject('modUser', $uid);
if ($user === null) {
/* orphaned post */
$output .= "\n <li>" . $doc->get('pagetitle') . '</li>';
// $doc->remove(); // uncomment if the results look OK
}
$output .= "\n</li>";
}
return $output;
I'm not sure if 'pagetitle' is the correct field. Maybe 'subject' would work with disPosts.
-
MODX Staff
- 2,502 Posts
Bob, that's handy but do you know if that will work with Discuss? IDK of Discuss uses a resource class or not. This is a bit of a strange app both integrated and separate from MODX. I think there is a thread topic and a reply title. I'd have to look at the model to be sure.
Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup
magician.
Blog ✦
Twitter ✦
LinkedIn ✦
GitHub
I'm pretty sure that disPost extends modResource, in which case it should work. If not, you could always use disPost instead of modResource (which might be faster anyway).
[ed. note: BobRay last edited this post 11 years, 10 months ago.]
forums.modx.com/thread/89917/how-to-export-contacts-from-ms-excel-to-vcard-vcf-file
Evolution user, I like the back-end speed and simplicity

Evolution user, I like the back-end speed and simplicity

Evolution user, I like the back-end speed and simplicity

forums.modx.com/u/zjdyshop
Evolution user, I like the back-end speed and simplicity

forums.modx.com/u/qizhen7733
Evolution user, I like the back-end speed and simplicity
