We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17301
    • 932 Posts
    Hi,

    I've been struggling with this one for the past 5-6 hours and I've no idea where I'm going wrong, any help is greatly appreciated.

    I've installed and setup the login package and that is all functioning well, as is the register functionality. I then installed the classExtender so that I can add in some extra fields on the registration and I've called it like this using the posthook..

    [[!Register?
    					&submitVar=`loginRegisterBtn`
    					...
    					&placeholderPrefix=`reg.`
    					&usernameField=`email`
    					&useExtended=`0`
    					&postHooks=`ExtUserRegisterPosthook`
    					]]


    I'm also currently just using the test data fields (title, firstName, lastName) supplied with classExtender so my form looks roughly like this..

    <form action="[[~[[*id]]]]" method="post" id="register-form">
    
    		<label for="email">Email</label>
    		<input type="text" name="email" id="email" value="[[!+reg.email]]" />
    
    		<label for="password">Password</label>
    		<input type="password" name="password" id="password" value="[[!+reg.password]]" />
    
    		<label for="title">Title</label>
    		<input type="text" name="title" id="title" value="[[!+reg.title]]">
    
    		<label for="first-name">First Name</label>
    		<input type="text" name="firstName" id="firstName" value="[[!+reg.firstName]]">
    
    		<label for="last-name">Last Name</label>
    		<input type="text" name="lastName" id="lastName" value="[[!+reg.lastName]]">
    
    	
    		<input type="submit" class="button" name="loginRegisterBtn" value="Register">
    
    </form>


    However on submission I'm getting this error:

    Fatal error: Call to a member function get() on a non-object in ***mydomain***/core/cache/includes/elements/modsnippet/66.include.cache.php on line 67


    Any ideas what I'm missing?

    Thanks,
      ■ email: [email protected] | ■ website: https://alienbuild.uk

      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
      • 3749
      • 24,544 Posts
      Which snippet has the ID 66?

      BTW, I don't think your custom fields should have the reg. prefix. Their names should match the field names.
        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
        • 17301
        • 932 Posts
        Hi Bob,

        Thank you for replying! I've just tried it without the .reg prefix and I'm still getting the same issue. The snippet with ID 66 is 'ExtUserRegisterPosthook'.

        Thanks!


          ■ email: [email protected] | ■ website: https://alienbuild.uk

          The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • 3749
          • 24,544 Posts
          You need a field called 'username' in order for the snippet to be able to find the user.
            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
            • 17301
            • 932 Posts
            Ah ok so &usernameField=`email` wouldn't work with the additional custom fields?

              ■ email: [email protected] | ■ website: https://alienbuild.uk

              The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
              • 3749
              • 24,544 Posts
              Not unless you modify the snippet.

              You could try changing this line:

              $userName = $hook->getValue('username');


              to this:

              $userName = $hook->getValue('email');


              Keep in mind that your change will be overwritten if you upgrade the ClassExtender package. If I have time, I'll add a &userNameField property for the next release.

              [Update]

              I've added the &userNameField property. You can see the modified file here: https://github.com/BobRay/ClassExtender/blob/dev/core/components/classextender/elements/snippets/extuserregisterposthook.snippet.php. The only change is replacing the line I mentioned above with this:

                  
                  $usernameField = $modx->getOption('usernameField', $scriptProperties, 'username', true);
                  $userName = $hook->getValue($usernameField);


              If you make that change and use &usernameField=`email` in the snippet tag, you'll be fine for future upgrades. (Note the spelling of the property name, I just changed it to match the Register property.)

              [ed. note: BobRay last edited this post 10 years, 4 months ago.]
                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