We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 35756
    • 166 Posts
    Hm...i got the admin-email sending by not using the "normal"-way:

    $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,'My Site');
    $modx->mail->set(modMail::MAIL_SENDER,'My Site');
    $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;


    Instead of the code above I had to use this one:

    <?php
    $headers .= "From: COMPANY<[email protected]>\n"; 
    $headers .= "BCC: <[email protected]>\n";
    $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; //
    
    $message = 'Hallo!
    
    <p>Ein neuer Benutzer hat sich angemeldet.</p>
    
    Benutzername: <strong>'.$hook->getValue('username')
     . '</strong><br />
    Email-Adresse: <strong>'.$hook->getValue('email').'</strong></p>
    
    Mit freundlichen Grüßen
    
    <p>';
    
    $to = "[email protected]";
    $subject = "Neue Anmeldung";
    
    
     if (mail($to, $subject, $message, $headers)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
      }


    So this is working now for me!

    But I still have troubles getting the general error-message displayed; I tried different variations for the placeholder:

    [[+reg.error.message]]
    [[+reg.error]]
    [[+reg.errors]]
    [[!+reg.error.message]]
    [[!+reg.error]]
    [[!+reg.errors]]
    


    But no output on this at all.

    Using the other placeholders like

    [[!+reg.error.fullname]]
    [[!+reg.error.username]]
    [[!+reg.error.password]]
    [[!+reg.error.password_confirm]]


    does work.

    So what can be the problem the general error-message doesn't get displayed?

    Furthermore my customer wants a "Forgot Username"-functionality; does anyone has done something like that before? I tried to do it on my own by copying the ForgotPassword-snippet and to dublicate the file at /core/components/login/controllers/web/ForgotPassword.php to ForgotUsername.php and edit this one, but without any luck so far.
      • 15558
      • 108 Posts
      thank you profilneurotiker for the code you shared ; i encounter exactly the same problems : the admin-email won't be sent if I use the code that is given in the official documentation (the "normal" way, like you said). Your code solved this. Again, thank you. [ed. note: kehezen last edited this post 9 years, 7 months ago.]
        Sorry for that ⇧ , I'm no dev but I wanna try
        • 35756
        • 166 Posts
        Hello kehezen!

        No problem!

        And, I did manage the general-error-message problem with a hard-coded workaround, see this thread:

        http://forums.modx.com/thread/93000/reg-error-message-not-working#dis-post-508097

        EDIT: Oh...I just saw the question about the general-error-message isn't inside your post anymore, but I read about this in the notify-email from the MODx-Forum. I guess you found my other thread or solved this in another way.
          • 36613
          • 328 Posts
          I have the same problem. I follow this guide:
          http://rtfm.modx.com/extras/revo/login/login.tutorials/login.using-pre-and-post-hooks
          i regive this error:
          [2015-07-05 14:18:04] (ERROR @ /index.php) Could not get table class for class: modAccess
          [2015-07-05 14:18:04] (ERROR @ /index.php) Could not get table name for class: modAccess
          [2015-07-05 14:18:04] (ERROR @ /index.php) Error 42000 executing statement: 
          Array
          (
              [0] => 42000
              [1] => 1064
              [2] => You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 55' at line 1
          )
          
          [2015-07-05 14:18:05] (ERROR @ /index.php) An error occurred while trying to send the email:


          In my registration, the user not confirm the registration but for confirm i use the ActivationEmail plugin. But i want advise the admin when the user do registration.
            • 40045
            • 534 Posts
            What about the built in "email" hook?

            And for the error message placeholder: try
            [[+error.message]]
            without the prefix... (e.g. no "reg." in front), does that help?