We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38304
    • 68 Posts
    I have some Custom-Inputfields (Userregistration) which where inserted in to extended Tab on Userinformation in Manager.

    I want to insert that custom input values into "comment" field at the First tab (General Userinformation)
    because i have to see e.g. the Name and Custom Information at once.

    So i think i have to do a preHook Snippet which collapses the single Inputs to a "comment" Post-variable.

    But something like this doesn't work...

    $email = $hook->getValue('email');
    $hook->setValue('comment',$email);


    It would be great if somebody could help me to get started...

    Thank you,
    Theo Retiker

      • 38304
      • 68 Posts
      <?php
      $comment = $hook->getValue('register.email').' '.$hook->getValue('register.user');
      $hook->setValue('register.comment',$comment);


      ?????? Userregistration hangs. I am calling this Snippet with &preHooks=`nameofsnippet`

        • 38304
        • 68 Posts
        So the fault is somewhere else?

        No answer after 18 hours.... sad

        Thank you,
        Theo Retiker
          • 38304
          • 68 Posts
          Ok, this is the wrong part.....

          $hook->setValue('register.comment',$comment);

          also an
          $hook->setValue('register.comment',$something);
          or
          $hook->setValue('comment',$something);
          doesn't work...

          The register. ones hangs the registration, while the 'comment' does registration but don't fill the comment Userinfo field.

          So the path is warong maybe...

          So maybe some Pro is able to help me getting the correct syntax for getting someting into usercomments please.

          Thank you,
          Theo Retiker
            • 3749
            • 24,544 Posts
            I'm not totally clear on what you're trying to do, but register.user is an object, not a string. This might be what you want:

            $userObj = $hook->getValue('register.user');
            $profileObj = $hook->getValue('register.profile');
            
            $userName = $userObj->get('username');
            $email = $userObj->get('email');
            
            
            $comment =  $username.' '.$email;
            
            $profileObj->set('comment', $comment);
            $profileObj->save();



            I'm not sure whether that should be a preHook or a postHook.


            ------------------------------------------------------------------------------------------
            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
              • 38304
              • 68 Posts
              Thank you very much for advise.

              (I noticed preHook and postHook are different in Formit and >Login.Register (after Validation but in front of Register User).)

              To clear:
              I had a Userregistrationform which included some Customfields (Inputs) and submit it.
              The Customfields appeared in Userinformation (Backend) under extended Values (Last Tab).

              My customer has to see all that Userinformation at once... not by clicking between the tabs...
              so my idea was how to get that customfield values off the extended Information Tab and get it at the "frontpage" of Userinformation.

              So i noticed a Comment-field there... i decided it to be the destination of the Custom values...
              the problem was how to get the Values of x Customfileds of Registrationformular into that one
              Commentfield in the first Tab of Userinformation.

              ########
              So, my advice for people which have the same Problem... i solved it already...
              doublecheck the Variable-Names in your Formular.

              The Problem is, if some or only one variablename is missing or wrong, Register hangs.
              If you use "return:true;" it runs forward but doesn't work at all...

              So, not only look for mistyping Variablename... check if they exist.

              My mistake has been:
              I had used the &usernameField=email of Login.register, so i got rid of the usernamefield.
              but then i asked for the usernamefield in my Commentcollapse-Snippet which did not exist,

              I checked everything... variablenames, mistyping, used every Snippet i could found... but don't realized that that username which appears in some Examples doesn't exist in my way.

              Because of no Error Message it had took a loong time to find this.

              So check misspelling/typing and existance of variablenames to get rid of that hang.

              Thank you very much, for your help... forgotten to close this Discussion. Sorry about that, and my bad english... it's not my native language.

              with best regards, and thank you
              Theo Retiker

                • 3749
                • 24,544 Posts
                I'm glad you got it sorted. Thanks for reporting back. smiley


                ------------------------------------------------------------------------------------------
                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