We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39587
    • 59 Posts
    Still no data going to extend user table. Register chuck now as follws:

    [[!Register? 
    &submitVar=`registerbtn` 
    &activationResourceId=`16` 
    &activationEmailTpl=`tblRegistrationEmail` 
    &activationEmailSubject=`Thanks for Registering!` 
    &validate=`nospam:blank, username:required:minLength=^6^, password:required:minLength=^6^, password_confirm:password_confirm=^password^, fullname:required, email:required:email,company:required:minLength=^3^` 
    &placeholderPrefix=`reg.`
    &useExtended=`0`
    &postHooks=`ExtUserRegisterPosthook`]]
    
    
    
    <div class="register">
      <div class="registerMessage">[[!+reg.error.message]]</div>
      
      <form class="form" action="[[~[[*id]]]]" method="post">
      
    	<input type="hidden" name="nospam" value="[[!+reg.nospam]]" />
    	
    	<label for="username">[[%register.username? &namespace=`login` &topic=`register`]]<span class="error">[[!+reg.error.username]]</span></label> 
    	<input id="username" type="text" name="username" value="[[!+reg.username]]" /><br>
    
    	
    	<label for="password">[[%register.password]]<span class="error">[[!+reg.error.password]]</span></label> 
    	<input id="password" type="password" name="password" value="[[!+reg.password]]" /> <br>
    	
    	
    	<label for="password_confirm">[[%register.password_confirm]]<span class="error">[[!+reg.error.password_confirm]]</span></label>
    	<input id="password_confirm" type="password" name="password_confirm" value="[[!+reg.password_confirm]]" /><br>
    	
    	<label for="fullname">[[%register.fullname]]<span class="error">[[!+reg.error.fullname]]</span></label> 
    	<input id="fullname" type="text" name="fullname" value="[[!+reg.fullname]]" /><br>
    	
    	<label for="email">[[%register.email]] <span class="error">[[!+reg.error.email]]</span></label> 
    	<input id="email" type="text" name="email" value="[[!+reg.email]]" /> <br class="clear" /><br>
    
    	<label for="company">[[%register.company]] <span class="error">[[!+reg.error.company]]</span></label> 
    	<input id="company" type="text" name="company" value="[[!+reg.company]]" /> <br>
    
    	
    	<div class="form-buttons"><input type="submit" name="registerbtn" value="Register" /></div>
    
      </form>
    
    </div>
      • 39587
      • 59 Posts
      Still no data going to extend user table. Register chuck now as follws:

      [[!Register? 
      &submitVar=`registerbtn` 
      &activationResourceId=`16` 
      &activationEmailTpl=`tblRegistrationEmail` 
      &activationEmailSubject=`Thanks for Registering!` 
      &validate=`nospam:blank, username:required:minLength=^6^, password:required:minLength=^6^, password_confirm:password_confirm=^password^, fullname:required, email:required:email,company:required:minLength=^3^` 
      &placeholderPrefix=`reg.`
      &useExtended=`0`
      &postHooks=`ExtUserRegisterPosthook`]]
      
      
      
      <div class="register">
        <div class="registerMessage">[[!+reg.error.message]]</div>
        
        <form class="form" action="[[~[[*id]]]]" method="post">
        
      	<input type="hidden" name="nospam" value="[[!+reg.nospam]]" />
      	
      	<label for="username">[[%register.username? &namespace=`login` &topic=`register`]]<span class="error">[[!+reg.error.username]]</span></label> 
      	<input id="username" type="text" name="username" value="[[!+reg.username]]" /><br>
      
      	
      	<label for="password">[[%register.password]]<span class="error">[[!+reg.error.password]]</span></label> 
      	<input id="password" type="password" name="password" value="[[!+reg.password]]" /> <br>
      	
      	
      	<label for="password_confirm">[[%register.password_confirm]]<span class="error">[[!+reg.error.password_confirm]]</span></label>
      	<input id="password_confirm" type="password" name="password_confirm" value="[[!+reg.password_confirm]]" /><br>
      	
      	<label for="fullname">[[%register.fullname]]<span class="error">[[!+reg.error.fullname]]</span></label> 
      	<input id="fullname" type="text" name="fullname" value="[[!+reg.fullname]]" /><br>
      	
      	<label for="email">[[%register.email]] <span class="error">[[!+reg.error.email]]</span></label> 
      	<input id="email" type="text" name="email" value="[[!+reg.email]]" /> <br class="clear" /><br>
      
      	<label for="company">[[%register.company]] <span class="error">[[!+reg.error.company]]</span></label> 
      	<input id="company" type="text" name="company" value="[[!+reg.company]]" /> <br>
      
      	
      	<div class="form-buttons"><input type="submit" name="registerbtn" value="Register" /></div>
      
        </form>
      
      </div>
        • 38783
        • 571 Posts
        Presumably each time you test the registration form you are creating a new user, with a unique user name and email address?
          If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

          email: [email protected] | website: https://andytough.com
          • 39587
          • 59 Posts
          email address is not unique becuase I am using my own email for the dummy users.

          Just test again this time no error generated in the log. I Think the error was due to me registering the same person twice because the email was not coming through.

          None the less the problem remains data not going to extended table from front end. However is works fine from the user manager form in the back end
            • 38783
            • 571 Posts
            Unless you have set MODX to allow duplicate email addresses that could cause a problem. I would try it with a different email address.

            You could also try amending your call to this:

            [[!Register? 
            &submitVar=`registerbtn` 
            &activationResourceId=`16` 
            &activationEmailTpl=`tblRegistrationEmail` 
            &activationEmailSubject=`Thanks for Registering!` 
            &validate=`nospam:blank, username:required:minLength=^6^:checkExists, password:required:minLength=^6^, password_confirm:password_confirm=^password^, fullname:required, email:required:email,company:required:minLength=^3^` 
            &placeholderPrefix=`reg.`
            &removeExpiredRegistrations=`0`
            &useExtended=`0`
            &postHooks=`ExtUserRegisterPosthook`]]


            This adds :checkExists to the user name which should warn you if MODX thinks the user already exists.
            It also adds the line &removeExpiredRegistrations=`0` which prevents new registrants from overwriting accounts set with the same user name where the first person has yet to verify their account using the link in the email.


              If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

              email: [email protected] | website: https://andytough.com
              • 39587
              • 59 Posts
              OK I have deleted all previous dummy users. Modified my call as you recommended. Registered as a new user with an email address that I have not used before.

              Outcome:-

              - Did prevent me from registering the same name twice
              - Still not sending data to extended table
              - No error generated in the log
              - Company entry not stored anywhere (checked the extended field its not in there)
                • 38783
                • 571 Posts
                I am going to test out your code on a modxcloud site. I will get back to you when I have had time to do this.
                  If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                  email: [email protected] | website: https://andytough.com
                  • 41592 ☆ A M B ☆
                  • 83 Posts
                  Why u don't use preHook and postHook?

                  in the posthook (when the user is correctly registered) you could use:
                  // Form fields
                  $formFields = $hook->getValues();
                  
                  // A reference to the modUser object
                  $user = $hook->getValue('register.user');
                  
                  // get custom class from user relation
                  $cc = $modx->getObject('yourCustomClassKeyTable',...);
                  if(!$cc){
                    // you're going to create it and populate
                    $cc = $modx->newObject('yourCustomClassKeyTable',...);
                  
                    $cc->fromArray($formFields);
                  
                    $cc->save();
                  }
                  



                  in the preHook you can ask to DB if already exist some informations to avoid duplicates
                  [ed. note: solidusite last edited this post 8 years, 6 months ago.]
                    Francesco Mussoni | MODX Ambassador | Skype: solidusite2 | Email: [email protected]
                    • 39587
                    • 59 Posts
                    Hi Guys,

                    Sorry I got side track the last couple of days. Any how did you go with the testing?

                    solidusite, I will explore your approach.

                    Cheers
                      • 38783
                      • 571 Posts
                      Not had a chance yet. I've been a bit snowed under. Hopefully I'll have time soon.
                        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                        email: [email protected] | website: https://andytough.com