<![CDATA[ Manual Activation - My Forums]]> https://forums.modx.com/thread/?thread=44830 <![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257885 Quote from: BobRay at Jan 10, 2011, 03:50 AM

Did you notice that there are two parts to the plugin? This part:

<?php
if ($mode == modSystemEvent::MODE_UPD) {
    if ( ! $user->get('active') && $_POST['active'] ) { 
        $modx->logManagerAction('activate_user','modUser',$user->get('id'));
        $email = $_POST['email']; 
        /* Code to Send email goes here */
    }
}


And the part that sends the email (which gets pasted exactly where the comment is)? I pasted both from working code, although It’s possible that something has changed in newer releases of 2.x.

Yes. I both noticed and understood from the beginning. When I didn’t see happening what I expected to, I eventually used just the above piece of code. Since it logs a manager action, then I’d be able to see that and know if I was buggering things up. I did NOT see any entries created in the manager log, hence my question. I’ll perhaps try experimenting a bit more, but this isn’t critical functionality for me.

On a positive note: News Publisher is! The concept is great (similar to what attracted me to Drupal before its bloat and poor performance turned me off).]]>
jrg Jan 10, 2011, 10:07 PM https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257885
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257884 ]]> boomerang Jan 10, 2011, 03:30 PM https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257884 <![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257883 ]]> BobRay Jan 10, 2011, 11:51 AM https://forums.modx.com/thread/44830/manual-activation?page=3#dis-post-257883 <![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257882 In the meantime below is some of my experience using Login (currenly on release 1.5.2)

I have followed all the instructions regarding setting up a registration page except as I didn’t want people to register automatically, so firstly I changed the response email to my own chunk. I used the following call on my registration page:

[[!Register? &submitVar=`registerbtn` &activationEmailTpl=`myRegistrationEmail` &activationEmailSubject=`Registration Submitted` &submittedResourceId=`17` &usergroups=`PrivateUserGroup` &postHooks=`hookNotifyAdminEmail` ]]

The custom chunk is myRegistrationEmail as follows:

<p>Hi, [[+username]],</p>

<p>Thanks for registering! Your application will be reviewed. On acceptance you will receive a confirmation email with details of where to login.</p>
<p>The password you registered was <strong>[[+password]]</strong> and your username is <strong>[[+username]]</strong>. Please keep these safe as you will require them when you are approved for login.</p>

<p>Kind regards,

<em>Site Administrator</em></p>

Instructions on the &postHooks=`hookNotifyAdminEmail` can be found in the Login documentation under Post Hooks. This allows notification to the Site Administrator that someone has registered on to site.

I then made use of the plugin the Bob provided using the following code:

<?php
if ($mode == modSystemEvent::MODE_UPD) {
if ( ! $user->get(’active’) && $_POST[’active’] ) {
$modx->logManagerAction(’activate_user’,’modUser’,$user->get(’id’));
$email = $_POST[’email’];
$name = $user->get(’username’);
$msg = "<p>Dear " . $name . ",</p>
<p>Thank you for registering at " . $modx->getOption(’site_name’,null,’My Site’) . ".</p>
<p>Your registration has been approved and you now access the Members area, please login <a href=’http://www.mywebsite.co.uk/login’>here</a>.</p>";
$msg .= "<p>Kind Regards,
Site Administrator</p>";
$subject = ’Registration Approved’;


$modx->getService(’mail’, ’mail.modPHPMailer’);
$modx->mail->set(modMail::MAIL_BODY, $msg);
$modx->mail->set(modMail::MAIL_FROM, $modx->getOption(’emailsender’));
$modx->mail->set(modMail::MAIL_FROM_NAME, $modx->getOption(’site_name’));
$modx->mail->set(modMail::MAIL_SENDER, $modx->getOption(’emailsender’));
$modx->mail->set(modMail::MAIL_SUBJECT, $subject);
$modx->mail->address(’to’, $email, $name);
$modx->mail->address(’no-reply-to’,’’);
$modx->mail->setHTML(true);
$sent = $modx->mail->send();
$modx->mail->reset();
}
}

I also selected under System Events onBeforeUserFormSave and everything works fine.

I am currently using Rev 2.0.4 as this site is being developed and will hopefully move this week to its own domain with Rev 2.0.6. I will test the manual activation again at that point and let you know if I experience any problems.

TIP: One thing I did find a little frustrating at first when using Login was that if I modified the chunks that came with the snippet any updates would overwrite my changes, so now I have created my own templates to prevent this from happening.

]]>
boomerang Jan 10, 2011, 05:04 AM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257882
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257881
<?php
if ($mode == modSystemEvent::MODE_UPD) {
    if ( ! $user->get('active') && $_POST['active'] ) { 
        $modx->logManagerAction('activate_user','modUser',$user->get('id'));
        $email = $_POST['email']; 
        /* Code to Send email goes here */
    }
}


And the part that sends the email (which gets pasted exactly where the comment is)? I pasted both from working code, although It’s possible that something has changed in newer releases of 2.x.]]>
BobRay Jan 09, 2011, 09:50 PM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257881
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257880 Quote from: BobRay at Jan 10, 2011, 02:18 AM

Plugins are notoriously hard to debug unless you have a debugger that will let you set breakpoints in the plugin and launch the manager.

Try implementing it as a snippet first that’s triggered with a snippet tag on a regular page. Set the necessary variables in parameters or at the top of the snippet. Once it’s working, paste it to your plugin.

If you’re not sure about your email capabilities, download the new QuickEmail snippet to test them.

The other plugin I mentioned gets user info and sends an e-mail message just fine. A copy-and-paste of your working example, doesn’t work for me. That’s what is bothering me!]]>
jrg Jan 09, 2011, 09:17 PM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257880
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257879
Try implementing it as a snippet first that’s triggered with a snippet tag on a regular page. Set the necessary variables in parameters or at the top of the snippet. Once it’s working, paste it to your plugin.

If you’re not sure about your email capabilities, download the new QuickEmail snippet to test them.]]>
BobRay Jan 09, 2011, 08:18 PM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257879
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257878
I went to the end solution and made some changes (essentially templated the plugin e-mail message) and... nothing.

After a lot of mucking around, including adding "$modx->log(modX::LOG_LEVEL_ERROR,’OnBeforeUserFormSave Debug(1): For...", I came to the conclusion the plugin wasn’t being run. Thinking I might have made some stupid coding error, I copy-and-pasted Bob’s code into my plugin (the code that only logs a manager action and has a comment instead of sending an e-mail message).

Guess what? there are absolutely no "activate_user" messages in my manager log. I’ve got the plugin tied to the OnBeforeUserFormSave event (I know how to do this as I have a previously developed plugin running just fine).

So, what am I missing?]]>
jrg Jan 09, 2011, 07:57 PM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257878
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257877
$msg = ’This is the message. Here is the URL: <a href="http//bobsguides.com">Bobs Guides</a>’;

Be sure to use single quotes on the outside and double quotes on the inside (only one pair of each). setHTML must be true. If that doesn’t do it, just post the code here that you’re having trouble with.]]>
BobRay Dec 07, 2010, 12:46 PM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257877
<![CDATA[Re: Manual Activation]]> https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257876
As you may have guessed this site isn’t quite live, it is due to launch early Jan 2010 and getting the restricted area right is essential - client is a Police Association group!

I have got a couple of other issues with Login which I’ve posted separately but I’m now so much closer to getting things working the way this client would like.

Thank you for your time. grin

Sorry just one more thing - how would I go about adding a url to the msg body - I have tried a variety of options but can’t seem to get the right string.]]>
boomerang Dec 07, 2010, 07:28 AM https://forums.modx.com/thread/44830/manual-activation?page=2#dis-post-257876