-
- 141 Posts
I currently have a site with 52 users which I need to update all of them with either of two new User Group's. Is there some sort of Batch tool that I could use for this?
Is this something that could be done through phpMyAdmin.
[*]
MODX Version: 2.2.8
[*]
PHP Version:5.3.26
[*]
Database: MySQL 5.1.70-cll
Thanks in advance.
Glyn Szasz
Sydney, Australia
Happy to help (when can) and happy to learn
If you are a Sydney based MODX developer would love to hear from you. Please contact me.
discuss.answer
-
- 24,544 Posts
The easiest way for me is a custom snippet like this (assuming that you want to add every user on the site to the two groups):
<?php
/* AddUsersToGroups snippet */
$userObjs = $modx->getCollection('modUser');
$count = count($userObjs);
foreach($userObject as $userObj) {
$userObj->joinGroup('GroupOne');
$userObj->joinGroup('GroupTwo');
}
return '<p>' . $count . " Users Updated";
If you had a lot more users, I'd recommend using getIterator() instead of getCollection().
-
- 141 Posts
Thank you, Bob that does the trick
Glyn Szasz
Sydney, Australia
Happy to help (when can) and happy to learn
If you are a Sydney based MODX developer would love to hear from you. Please contact me.