On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi,

    Back on my register debugging.
    I'm focusing on the validation process and nothing is sent (no trace of anything in my server's mailog nor in modx error log)

    My users are actually created but the validation email is just not existing. (While no pb with Formit contact form)

    I tried to create a postHook stuff to see more and everything is ok to send a short msg to me telling there's a new user.
    I managed this post hook (probably very badly, I'm not php dev) to add another sending to the concerned new user too. this email is sent too by the posthook snippet.
    How to add needed place holder (especially the +confirmurl) in this code ?
    Thank you.

    /* 1er envoi msg de validation au user */
    $message = $modx->getChunk('lgnActivateEmailTpl');
    /* we get the standard email tpl normally used by Register snippet */
    
    $useremail = $hook->getValue('ORDER_email');
    $modx->getService('mail', 'mail.modPHPMailer');
    $modx->mail->set(modMail::MAIL_BODY,$message);
    $modx->mail->set(modMail::MAIL_FROM,'XXX@mydomain.tld');
    $modx->mail->set(modMail::MAIL_FROM_NAME,'xxxxxxx');
    $modx->mail->set(modMail::MAIL_SENDER,'Site xxxxx');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New User Signed Up');
    $modx->mail->address('to',$useremail);
    $modx->mail->address('reply-to','XXX@mydomain.tld');
    
    $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();
    
    
    /*  second envoi copie admin */
    
    $modx->getService('mail', 'mail.modPHPMailer');
    $modx->mail->set(modMail::MAIL_BODY,$message);
    $modx->mail->set(modMail::MAIL_FROM,'XXX@mydomain.tld');
    $modx->mail->set(modMail::MAIL_FROM_NAME,'xxxxxxx');
    $modx->mail->set(modMail::MAIL_SENDER,'Site xxxxx');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New User Signed Up');
    
    $modx->mail->address('cc','yyyy@mydomain.tld ');
    $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;
    • Here's a working Register snippet
      [[!Register?
      &submitVar=`registerbtn`
      &activationResourceId=`10`
      &activationEmailTpl=`MylgnActivationEmailTpl`
      &activationEmailSubject=`Please activate your account`
      &submittedResourceId=`11`
      &usergroups=`WebUsers`
      &successMsg=`Your registration was successful`
      ]]


      And the MylgnActivationEmailTpl
      <p>[[+fullname]],</p>
      
      <p>Thanks for registering with My Site! To activate your new account, please click on the following link:</p>
      
      <p><a href="[[+confirmUrl]]">[[+confirmUrl]]</a></p>
      
      <p>After activating, you may login with your password and username:</p>
      
      <p>
      Username: <strong>[[+username]]</strong><br />
      Password: <strong>[[+password]]</strong></p>
      
      <p>If you did not request this message, please ignore it.</p>
      
      <p>Thanks,<br />
      <em>My Site</em></p>
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
      • Hi Susan,
        thank you but this is exactly what is not working here and I don't have any clue why Register activation does not do the emailing job and this is why I was trying to find another way to send the activation email with a posthook!

        As I posted : "nothing is sent (no trace of anything in my server's mailog nor in modx error log)" with the basic Register call:

        This one (without posthook first then with my posthook):
        [[!Register?
        &submitVar=`registerbtn`
        &activation=`1`
        &activationEmailTpl=`lgnActivateEmailTpl`
        &activationEmailSubject=`Please activate your account!`
        &activationResourceId=`54`
        &submittedResourceId=`53`
        &useExtended=`1`
        &emailField=`ORDER_email`

        &usergroups=`Members`
        &validate=`nospam:blank,
        username:required:minLength=^6^,
        password:required:minLength=^6^,
        password_confirm:password_confirm=^password^,
        ORDER_fname:required
        `
        &placeholderPrefix=`reg.`
        &postHooks=`RegisterHookEmail`

        ]]

        Now in mu posthook I changed the $message création like this:
        $message = $modx->getChunk('lgnActivateEmailTpl',$hook->getValues() );

        This solve my issue regarding populating the placeholders coming from the register form but of course not for the +confirmurl.
        So How to get the confirm url in a posthook ?

        • Hi all !


          I found there's a %$$!## bug within Register activation management!

          I just did a test adding in my registration form a 2nd email field named 'email' (in addition of the one I actually wanna use named 'ORDER_email' and...bingo the activation process is working now.
          This is a real pain because this means
          &emailField=`ORDER_email`
          in the Register call even if it seams to work (because it populated well the classic email user profil field)is actually not BECAUSE Register is not able to use ANOTHER named field that 'email' to send the validation email..!
          [ed. note: elz064 last edited this post 4 years, 8 months ago.]