We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    Back when I used to use Etomite, I had a script that sent messages from a contact form into my "inbox" in the Manager.

    Does anyone know if there’s a similar script for MODx?
      My Snippets
      -> PopUpChunk v1.0
      • 21257 MODX Staff
      • 730 Posts
      This core function looks like it would do the job:

          # sends a message to a user's message box
          function sendAlert($type, $to, $from, $subject, $msg, $private= 0) {
          ...
          }
      


      So inside a snippet, it should be as simple as..

      $modx->sendAlert($type, $to, $from, $subject, $msg, $private);
      


      Now, if you’re programming your own snippet, that’s great, but the question is: what are those parameters all about?

      $type - I think you want this to be the string "Message" (maybe it can take other values, but I’m not sure what they are)
      $to - can be the id of the user or the username
      $from - can be the id of the user or the username
      $subject - text of subject line
      $msg - text of message
      $private - should be 1 for a private message (not sure how to send messages to a group or to everyone)

      If you’re not incorporating this into some snippet you’re working on, and you just want a snippet who’s only function is to send a message to a user, then you could do this:

      Make a new snippet, let’s call it "SendMessage":

      <?php
      /**
       * SendMessage 0.1
       * Send a private message to a user
       */
      $modx->sendAlert("Message", $to, $from, $subject, $msg, 1);
      return '';
      ?>
      


      And your snippet call could look like this:
      [[SendMessage? &to=`user1` &from=`1` &subject=`test subject` &msg=`test message` ]]
      

      (I set the from user to 1 because that should always be the id of the default admin user.)

      I haven’t tried this out.. beware!! tongue
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell