We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42146
    • 73 Posts
    Looking to do the same, though working i see some issues i'm not sure about.

    added post hook to your register call
    [[!Register?
    &postHooks`GenerateUserDirectory`
    ]]

    Create a plugin called GenerateUserDirectory
    <?php
    if  ($mode == modSystemEvent::MODE_NEW) {
    
    $userName = $user->get('username');
          
        $dir = (boolean)$modx->getOption('filemanager_path_relative',null,false) ? $modx->getOption('base_path') : '';
        $dir .= $modx->getOption('filemanager_path',null,'').'assets/userfiles/'.$userName;
        $folder_permissions = octdec($modx->getOption('new_folder_permissions'));
        if (!@mkdir($dir,$folder_permissions)) {
            $modx->log(modX::LOG_LEVEL_ERROR,'Could not create user directory: '.$dir);
        }
        return true;
    
    }


    on system events tick the OnUserSave


    In checking my error logs did notice that i get these errors when registering a new user.
    [2012-12-15 05:03:06] (ERROR @ /modx-2.2.5-pl/index.php) [OnUserSave]1
    [2012-12-15 05:03:06] (ERROR @ /modx-2.2.5-pl/index.php) [Login] Could not find hook "GenerateUserDirectory".

    when checking file manager i do see a folder created with user names.. not sure why i'm getting the login error not sure what the [OnUserSave]1 means


    christianhanvey
    I also had to create the 'new_folder_permissions' in the System Settings

    I didn't create any new_folder_permissions though when looking at creating this new system setting. i'm unsure how to go about this.... so i'm guessing this is what it should be

    key=new_folder_permissions
    name=new_folder_permissions
    fieldtype=textfield
    namespace=core
    value= 0755
    [ed. note: jstump last edited this post 11 years, 5 months ago.]