We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39389
    • 9 Posts
    Hello, i need some help from expierenced Modx users on my new project.

    I want a site where manager can add user.

    These users have their own extended fields (some images and a pdf file) and it will be a folder created. The one with the folder I already solved with discussion forums posts.


    Plugin (OnUserFormSave)
    if  ($mode == modSystemEvent::MODE_UPD) {
    
       //an eMail should go to the user
        return true;
    }
    
    if  ($mode == modSystemEvent::MODE_NEW) {
        
    $userName = $user->get('username');
        $userID = $user->get('id');
         
        $dir = (boolean)$modx->getOption('filemanager_path_relative',null,false) ? $modx->getOption('base_path') : '';
        $dir .= $modx->getOption('filemanager_path',null,'').'assets/kunden/'.$userID.' '.$userName;
        $folder_permissions = octdec($modx->getOption('new_folder_permissions'));
        if (!@mkdir($dir,$folder_permissions)) {
            $modx->log(modX::LOG_LEVEL_ERROR,'Konnte ordner nicht erstellen: '.$dir);
        }
        
    // I dont know what but something is wrong here in the code  
    
        $profile = $user->getOne('Profile');
        $extended = array();
        $extended = $profile->get('extended');
        $extended[] 'field1' => 'TestValue 1';
        $extended[] 'field2' => 'Test Value 2';
        $profile->set('extended', $extended);
        $profile->save();
    
        return true;
    }


    It works with the user folder but dont work with the extended fields.
    In one of these extended fields schould be the new created path to the user folder.

    The best way where if I create a new user that this user get an email notification with his login data.
    If I update the User e.g. I put a PDF in the extended field called pdfpath the user will get an email notification about some updates on his profile.






      • 3749
      • 24,544 Posts
      Have you looked at the Subscribe and SubscribeMe extras? They will handle sending the email for you.

      Your code to update the Profile looks good to me, though you should check to make sure you have a profile before calling get() on it.

      if (empty($profile)) {
        /* failed to get the profile */
      } else {
        /* do your stuff */
      }
      

      What, exactly, is happening when it runs?


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 39389
        • 9 Posts
        Thanks,
        can I easily change this extensions ? Because that service is without payment.
        This schould be an service for customers that ive registered at first.
        Later I will make an normal registration for all.

        How I create custom extended fields with custom content ?
          • 3749
          • 24,544 Posts
          Sorry, I'm not sure I understand your first question. For the second question -- you're doing it correctly in the code above as far as I can tell.

          If you want to see if a user is logged and is a member of a certain group, you can use:

          if ($modx->user->hasSessionContext($modx->context->get('key')) {
              if ($modx->user->isMember('Subscribers')) {
                 /* user is logged in and belongs to the group */
              }
          }



          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting