Quote from: sottwell at Jun 17, 2014, 09:18 PMYes. the "OptionalRoleNameOrId" is optional, and is to indicate the role in the assign group. Roles are a rather obscure topic. http://rtfm.modx.com/revolution/2.x/administering-your-site/security/roles
The $modx->user object is the current user; if you need to specify a user you first have to create the $user object.
$user = $modx->getObject('modUser', array('username'=>$username));
$user->joinGroup($joingroup);
So, sottwell, from
$user = $modx->getObject('modUser', array('username'=>$username));
$user->joinGroup($joingroup);
it is correct to infer that the "user object" is initialised for the username that is specified with "
$username", and thus, the user object is that of a user of my own choice, rather than that of the current / visiting user.
Also, from using the external initialization (
http://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/loading-modx-externally ) the following code will allow me to use the MODx functions/classes that we're using here, from a .php file located in a sub-directory of my MODx installation?
require_once '/absolute/path/to/modx/config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
On a side note, does this mean that if anyone knew where my config.core.php file was located, they could run MODx functions from their own php scripts, and change things like permissions of accounts, etc.
Thanks again for the help!
[ed. note: muffinjello last edited this post 9 years, 10 months ago.]