MODX Community

Default media source per usergroup or user

Is there a way to set a default_media_source per usergroup or user? Neither the setting for the user or the user group takes effect.

Thanx a lot,
Jan

When a user logs in, the System Setting are read, then overridden by any User Settings or User Group Settings with matching keys, so what you’re describing shouldn’t ever happen unless MODX is ignoring the default_media_source setting altogether.

Make sure your setting is spelled exactly like the System Setting.

Make sure the setting contains the ID of media source, not the name.

Clear the site cache, flush permissions, and log out all users before testing.

If that doesn’t work, try manually deleting all files in the core/cache directory.

Hi bobray,
thanks a lot for your help. I tried everything exactly as you suggested. MODX is still ignoring this settings. Is that may a bug? Should i report that as an issue in the GitHub-Repo?

I did a quick test and the user settings only seem to take affect, if I first call getUser() (with the second parameter $forceLoadSettings set to true).

<?php
//public function getUser($contextKey= '',$forceLoadSettings = false) { ... }
$modx->getUser('', true);
return $modx->getOption('default_media_source');

Did you try User Settings or User Group Settings? It’s entirely possible that User Group Settings don’t work, if so, that should be reported as a bug, but User Settings have always worked for me. If they don’t that should probably be reported as well.

The suggestion from halftrainedharry is excellent, but it really shouldn’t be necessary if permissions are flushed and everyone is logged out.