Skip to content

Instantly share code, notes, and snippets.

@hissy
Created February 11, 2022 12:20
Show Gist options
  • Save hissy/1ff637b079551fe5619e545676641ff4 to your computer and use it in GitHub Desktop.
Save hissy/1ff637b079551fe5619e545676641ff4 to your computer and use it in GitHub Desktop.
#ConcreteCMS Tiny script to anonymize users
<?php
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\User\UserInfoRepository;
$app = Application::getFacadeApplication();
/** @var UserInfoRepository $repository */
$repository = $app->make(UserInfoRepository::class);
$updated = 0;
$failed = 0;
foreach ($repository->all() as $userInfo) {
$uID = $userInfo->getUserID();
$userInfo->setAttribute('profile_private_messages_notification_enabled', false);
$result = $userInfo->update([
'uEmail' => sprintf('user%[email protected]', $uID)
]);
if ($result) {
$updated++;
} else {
$failed++;
}
}
echo sprintf('Anonymize Completed. %d users updated, %d users failed.', $updated, $failed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment