We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Try putting this at the top of the plugin, then check the error log to see if the code is executing at all:

    $modx->log(modX::LOG_LEVEL_ERROR,'IN PLUGIN');


    In addition, I had a syntax error in the code.

    It should be:

    $message .= ' with email ' . $profile->get('email');

      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
      • 36426
      • 197 Posts
      Hi thanks Bob, it was the syntax error in the code that caused the problem, now it's corrected it works great! Thank you!
        Yorkshire UK based hosting provider: https://www.simulant.uk
        • 3749
        • 24,544 Posts
        I'm glad you got it working. smiley
          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
          • 36426
          • 197 Posts
          Thanks Bob. Just one last thing now it's working; Do you know how I add custom or extended fields to this email report.

          I tried adding the code as below:

          $message = 'A new user has registered: '.$user->get('username');
          $profile = $user->getOne('Profile');
          if ($profile) {
          $message .= ' with email ' . $profile->get('email');
          $message .= ' Option1, Option2 or Option3 selected: ' . $profile->get('option1option2option3');
          }
          $modx->getService('mail', 'mail.modPHPMailer');
          $modx->mail->set(modMail::MAIL_BODY,$message);
          $modx->mail->set(modMail::MAIL_FROM,'[email protected]');
          $modx->mail->set(modMail::MAIL_FROM_NAME,'Website');
          $modx->mail->set(modMail::MAIL_SENDER,'Website');
          $modx->mail->set(modMail::MAIL_SUBJECT,'New User Registration');
          $modx->mail->address('to','email address here');
          $modx->mail->setHTML(true);
          if (!$modx->mail->send()) {
              $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
          }
          $modx->mail->reset();
          /* tell our snippet we're good and can continue */
          return true;


          But now on the confirmation/notify email I just get the text: "Option1, Option2 or Option3 selected:" but with nothing after it. My field is called option1option2option3, so I must just not be pulling the info out correctly?

          Thanks for any help again.
            Yorkshire UK based hosting provider: https://www.simulant.uk
            • 3749
            • 24,544 Posts
            Try this instead of line 5:

            $extended = $profile->get('extended');
            $fieldNames = array(
                'Option1',
                'Option2',
                'Option2'
            );
            $fields = array();
            foreach ($fieldNames as $fieldName) {
                if (isset($extended[$fieldName])) {
                    $fields[] = $extended[$fieldName];
                }
            }
            
            $msg = implode(', ', $fields);
            
            


            This is a good example of why I dislike using Profile extended fields to store user data. wink
            [ed. note: BobRay last edited this post 10 years, 2 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
              • 36426
              • 197 Posts
              Quote from: BobRay at Mar 19, 2014, 05:31 PM
              Try this instead of line 5:

              $extended = $profile->get('extended');
              $fieldNames = array('Option1', 'Option2', 'Option2');
              $fields = array();
              foreach ($fieldNames as $fieldName) {
                 if isset($extended[$fieldName]) {
                    $fields[] = $extended[$fieldName];
                 }
              }
              
              $msg = implode(', ', $fields);
              


              This is a good example of why I dislike using Profile extended fields to store user data. wink

              Hi Bob, thanks again - this unfortunately though is now not letting me register again as if there is another error in the syntax? sad
                Yorkshire UK based hosting provider: https://www.simulant.uk
                • 36426
                • 197 Posts
                Hi another problem I've now noticed is my form isn't showing validation errors for Register. It works ok for Login (ie. "That account could not be located. Check the username and re-type the password to try again." etc) but Register is no longer working. I'm not sure when it stopped working, it must have been at some point as I added more fields and parts to my form. Here is the code:

                <div class="col_6">
                <h5>Already Registered? Please Login Below</h5>
                [[!Login? &loginTpl=`lgnLoginTpl` &logoutTpl=`lgnLogoutTpl` &errTpl=`lgnErrTpl` &loginResourceId=`1` &logoutResourceId=`1`]]
                <p>Forgotten Password? <a title="Forgotten Password Reset" href="[[~13]]">Please click here to reset your password</a>.</p>
                <p> </p>
                <h5>Self-Certification</h5>
                <p><strong>Please Note:</strong> Before registering as a Saver or Lender you must sign the relevant forms for Self-Certification as a High Net Worth Individual or a Sophisticated Investor.</p>
                <br />
                <p><a class="button blue" title="Self-Certification as a High Net Worth Individual or a Sophisticated Investor" href="[[~16]]">Read & Sign Forms</a></p>
                </div>
                <div class="col_6">
                <h5>Register An Account</h5>
                [[!Register? &usergroupsField=`saver,lender,developer` &submitVar=`registerbtn` &activationResourceId=`11` &activationEmailTpl=`myActivationEmailTpl` &activationEmailSubject=`Thanks for Registering!` &submittedResourceId=`10` &customValidators=`customvalidators`; &validate=`nospam:blank, username:required:minLength=^6^, password:required:minLength=^6^, password_confirm:password_confirm=^password^, fullname:required, saverlenderdeveloper:required, email:required:email` &placeholderPrefix=`reg.`  ]]
                <div class="register">
                <div class="registerMessage">[[!+reg.error.message]]</div>
                <form class="form" action="[[~[[*id]]]]" method="post"><fieldset name="register"><legend class="registerLegend">Register</legend> <input type="hidden" name="nospam" value="[[!+reg.nospam]]" /> <label for="username"><label for="username">[[%register.username? &namespace=`login` &topic=`register`]]</label></label> <span class="error">[[!+reg.error.username]]</span> <input id="username" type="text" name="username" value="[[!+reg.username]]" />
                <p> </p>
                <label for="fullname">[[%register.fullname]] <span class="error">[[!+reg.error.fullname]]</span> </label> <input id="fullname" type="text" name="fullname" value="[[!+reg.fullname]]" />
                <p> </p>
                <label for="email">[[%register.email]] <span class="error">[[!+reg.error.email]]</span> </label> <input id="email" type="text" name="email" value="[[!+reg.email]]" />
                <p> </p>
                <label for="password">[[%register.password]] <span class="error">[[!+reg.error.password]]</span> </label> <input id="password" type="password" name="password" value="[[!+reg.password]]" />
                <p> </p>
                <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]]" />
                <p> </p>
                <p>Are you a Saver, Lender or Developer?</p>
                <label for="saverlenderdeveloper">Please Select One</label><select id="saverlenderdeveloper" name="saverlenderdeveloper">
                <option value="Saver">Saver</option>
                <option value="Lender">Lender</option>
                <option value="Developer">Developer</option>
                </select>
                <p><strong>Savers & Lenders Only:</strong> Please confirm one of the following: *</p>
                <ul style="list-style: none;">
                <li><input type="hidden" name="highnetworth" value="[[+highnetworth:default=``]]" /> <input id="highnetworth" class="checkbox" type="checkbox" name="highnetworth" value="[[+highnetworth:default=`High Net Worth`]]" /> <label class="checkbox-label" for="highnetworth-checkbox">I have signed the Self-Certified High Net Worth Individual Statement</label></li>
                <li><input type="hidden" name="sophisticatedinvestor" value="[[+sophisticatedinvestor:default=``]]" /> <input id="sophisticatedinvestor" class="checkbox" type="checkbox" name="sophisticatedinvestor" value="[[+lender:default=`Sophisticated Investor`]]" /> <label class="checkbox-label" for="sophisticatedinvestor-checkbox">I have signed the Self-Certified Sophisticated Investor Statement</label></li>
                </ul>
                <p> </p>
                <br class="clear" />
                <div class="form-buttons"><input type="submit" name="registerbtn" value="Register" /></div>
                </fieldset></form></div>
                </div>


                Any ideas what may be causing this? Thanks for any help.
                  Yorkshire UK based hosting provider: https://www.simulant.uk