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