Monday 03 March 2008 3:27:52 pm
Hi Fabrice Here you go: <?php
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/datatypes/ezuser/ezusersetting.php' );
include_once( 'kernel/classes/ezcontentobjecttreenodeoperations.php' );
include_once( 'lib/ezutils/classes/ezfunctionhandler.php' );
// Content Class ID of the user objects we want to purge
$userContentClassID = 44;
// Grab eZuser objects that are not activated
$users =& eZPersistentObject::fetchObjectList( eZUserSetting::definition(),
null,
array('is_enabled' => 0),true);
if($users)
{
// build an array of user_ids
$userIDs=array();
foreach (array_keys($users) as $index)
{
$userSettings =& $users[$index];
$userIDs[]=$userSettings->attribute('user_id');
}
// Get user content objects that were created more that a week ago
$weekAgo = time()-3600*24*7;
$cond = array('contentclass_id' => $userContentClassID,
'id' => array($userIDs),
'published' => array( '<', $weekAgo ) );
$userObjects=eZPersistentObject::fetchObjectList( eZContentObject::definition(), null, $cond,true);
if ($userObjects)
{
foreach (array_keys($userObjects) as $index)
{
$userObject =& $userObjects[$index];
// Remove user
$userObject->purge();
}
}
}
?>
This code removes users that are not active that have been created more than a week ago. Make sure you set the $userContentClassID value to the Content class Id of the user class you want to purge. I tend to create a specific "community" user class that is different to the user classes used for admin's & editors...just to be on the safe side. We don't want there removed!
Cheers Bruce
My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish
|