We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34108
    • 66 Posts
    Hi, I’m using the Login package (which is awesome btw, thank you again Shaun!) and it’s all working beautifully except for one thing which is, unfortunately, critical to my client’s project.

    Basically, when a new user registers the form needs to first send an email to the site administrator so they can manually activate the new user. I’ve attempted to do this via the instructions in the official doco (Register custom email postHook) - http://rtfm.modx.com/display/ADDON/Login.Using+Pre+and+Post+Hooks - as well as by the code in Muggins’ great tutorial - http://modxcms.com/forums/index.php/topic,60982.0.html - but neither method works.

    Hori is also having the same problem - http://modxcms.com/forums/index.php/topic,60529.0.html

    The form is sending off an email to the new user just fine, so it’s clearly working, but nothing arrives in the administrator’s inbox regardless of the email address used.

    I’ve included my specs and code below - if you need any more info just let me know. Any help anyone can give would be very very much appreciated! Thank you smiley


    • MODx Revolution 2.0.7-pl (traditional)
    • PHP Version 5.2.10
    • MySQL Version 5.0.91

    Registration form (Template)

    [[!Register? 
        &submitVar=`registerbtn` 
        &activationEmailTpl=`RegistrationEmail`
        &activationEmailSubject=`Thanks for registering for the IGA Retailer portal`
        &submittedResourceId=`95` 
        &usergroups=`IGA Store Owners`
        &postHooks=`hookNotifyAdminEmail`
    ]]
    
    <div id="retailer-form">
    
        <div class="registerMessage">[[+error.message]]</div>
         
        <form class="form" action="[[~[[*id]]]]" method="post">
    
        <input type="hidden" name="nospam:blank" value="" />
     
        <fieldset>
    
            <legend>Store Details</legend>
    
            <label for="store">Store name <span class="required">*</span>
                <span class="error">[[+error.store]]</span>
            </label>
            <input type="text" name="store:required" value="[[+store]]" />
    
            <label for="address">Street address <span class="required">*</span>
                <span class="error">[[+error.address]]</span>
            </label>
            <input type="text" name="address:required" id="address" value="[[+address]]" />
     
            <label for="city">Town / Suburb <span class="required">*</span>
                <span class="error">[[+error.city]]</span>
            </label>
            <input type="text" name="city:required" id="city" value="[[+city]]" />
     
            <label for="state">State</label>
            <input type="text" name="state" id="state" value="TAS" readonly />
     
            <label for="zip">Postcode <span class="required">*</span>
                <span class="error">[[+error.zip]]</span>
            </label>
            <input type="text" name="zip:required" id="zip" value="[[+zip]]" />
     
            <label for="phone">Phone <span class="required">*</span>
                <span class="error">[[+error.phone]]</span>
            </label>
            <input type="text" name="phone:required" id="phone" value="[[+phone]]" />
    
            <label for="fax">Fax
                <span class="error">[[+error.fax]]</span>
            </label>
            <input type="text" name="fax" id="fax" value="[[+fax]]" />
     
            <label for="website">Website
                <span class="error">[[+error.website]]</span>
            </label>
            <input type="text" name="website" id="website" value="[[+website]]" />
    
        </fieldset>
    
        <fieldset>
    
            <legend>Owner Details</legend>
    
            <label for="fullname">[[!%login.fullname? &namespace=`login` &topic=`updateprofile`]] <span class="required">*</span>
                <span class="error">[[+error.fullname]]</span>
            </label>
            <input type="text" name="fullname:required" id="fullname" value="[[+fullname]]" />
     
            <label for="email">Email <span class="required">*</span>
                <span class="error">[[+error.email]]</span>
            </label>
            <input type="text" name="email:required" id="email" value="[[+email]]" />
    
            <label for="mobilephone">Mobile Phone
                <span class="error">[[+error.mobilephone]]</span>
            </label>
            <input type="text" name="mobilephone" id="mobilephone" value="[[+mobilephone]]" />
    
            <label for="username">[[%register.username? &namespace=`login` &topic=`register`]] <span class="required">*</span>
                <span class="error">[[+error.username]]</span>
            </label>
            <input type="text" name="username:required:minLength=6" id="username" value="[[+username]]" />
             
            <label for="password">[[%register.password]] <span class="required">*</span>
                <span class="error">[[+error.password]]</span>
            </label>
            <input type="password" name="password:required:minLength=6" id="password" value="[[+password]]" />
             
            <label for="password_confirm">[[%register.password_confirm]] <span class="required">*</span>
                <span class="error">[[+error.password_confirm]]</span>
            </label>
            <input type="password" name="password_confirm:password_confirm=`password`" id="password_confirm" value="[[+password_confirm]]" />
     
        </fieldset>
    
        <input type="submit" name="registerbtn" value="Register" class="submit" />
    
        </form>
    
    </div>
    
    


    hookNotifyAdminEmail (snippet)

    <?php
    $message = 'Hi, a new User signed up: '.$hook->getValue('username')
     . ' with email '.$hook->getValue('email').'.';
     
    $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,'New user registration request');
    $modx->mail->set(modMail::MAIL_SENDER,'IGA Tasmania');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New User Signed Up');
    $modx->mail->address('to','[email protected]');
    $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;
    

      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I know this is an old post (sorry!) but I had some weird problems with email on my server due to system settings related to the DNS entries, specifically the entries in these files:

      /etc/localdomains
      /etc/remotedomains

      It’s so hard to troubleshoot email problems... it could be a script problem, or it could be something entirely outside of your control.
        • 3749
        • 24,544 Posts
        If the send fails while MODX is handling it, it should put an error in the MODX error log. It might contain helpful information.

        Are you using SMTP? If not, that might be an option.

        You could also try installing QuickEmail and calling it with $modx->runSnippet() in your postHook to see what that gets you.
          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
          • 3866 ☆ A M B ☆
          • 350 Posts
          Hi there, this snippet does work in so far as it fires an email to notify that a new user has registered, however, it does not fill in the username, fullname and email for the message.

          I have logged a bug http://bugs.modx.com/issues/5823 and hopefully this will be resolved soon.

          For info it worked with Login 1.6.5 on Revo 2.1.3 but doesn't work with Login 1.7.0 rc2.
            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel
            • 3749
            • 24,544 Posts
            I've seen several posts with similar problems. Until a new version comes out (or information on how to make the placeholders work), you might just downgrade to 1.6.5.
              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
              • 3866 ☆ A M B ☆
              • 350 Posts
              Tried to downgrade but there has clearly been quite a change from version 1.6.5 to 1.7.0 as it has completely mucked up all the Login features.

              Re-installed 1.7.0 and all works a part from the postHook providing admin with details of the new user - at worst the email is received and notifies the fact a new user has registered, so its a case of logging on to manager to see who!

              I'm sure the snippet for postHook is all that needs to be changed in order to access the username, fullname and email. Have tried setValue but that doesn't work either.
                Helen Warner
                Number one pixel!
                Proud to be linked with MODX at Crimson Pixel
                • 3866 ☆ A M B ☆
                • 350 Posts
                Thanks to Splittingred we now have an updated version, which works with &postHooks. Make sure you are using Revo 2.1.x plus to ensure this latest Login version works. [ed. note: boomerang last edited this post 14 years, 11 months ago.]
                  Helen Warner
                  Number one pixel!
                  Proud to be linked with MODX at Crimson Pixel