-
- 5,888 Posts
how did you call that snippet?
-
- 5,888 Posts
thats looking good, but try this snippet, it gives maybe a bit more information, what happens:
<?php
$removeresources = '111,112,999999,9998888';
$removeresources = explode(',',$removeresources);
foreach ($removeresources as $id) {
if ($doc = $modx->getObject('modResource',$id)){
if ($doc->remove()){
echo 'removed ' . $id . '<br>';
} else {
echo 'could not remove ' . $id . '<br>';
}
} else {
echo 'could not find ' . $id . '<br>';
}
}
-
- 5,888 Posts
are you logged into the manager and you are sure, you have permissions to load that resources?
maybe you should check, to be sudo-user
check also the MODX - errorlog
-
- 24,544 Posts
I suspect that it's because the snippet is running in the front end. When you view the front end from the Manager, you're the anonymous user. You need to explicitly log in to the front end as the admin using the Login snippet.
-
- 24,544 Posts
Try changing the getObject() line to this:
if ($doc = $modx->getObject('modResource',(int) $id)){