We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21800
    • 174 Posts
    Hello,
    in wlpe I want to replace the sendMessageToUser function with the eForm functions. So from a given UserID that wlpe delivers as [+view.internalKey+] placeholder it needs to excerpt the adequate email adress to handover to eForm call.

    Any help is appreciated.
      • 7155
      • 160 Posts
      Name the snippet GetEmail

      Then call it likewise:
      [[GetEmail? &userid=`[+view.internalKey+]`]]
      

      Snippet:

      <?php
      /*
      usage [[GetEmail? &userid=`[+internalKeyPlaceholderOrValue+]`]]
      Returns users email from an internalKey
      */

      $userid = isset($userid)? $userid : false;

      function getEmail($id)
      {
      global $modx;
      $id = intval($id);

      $table = $modx->getFullTableName(’web_user_attributes’);

      $sql = "SELECT email FROM $table WHERE internalKey = $id LIMIT 1";

      if($result = $modx->db->query($sql))
      {
      $row = $modx->db->getRow($result);
      return $row[’email’];
      }
      else
      return;//nothing found!!!
      }

      if($userid)
      return getEmail($userid);
      ?>
      Havent tested it but should work. Let me know if you have problems.

      EDIT:
      removed ’modx_’
        • 21800
        • 174 Posts
        Thanx for your kind help designetic,

        but something failes yet. When I removed "modx_" from the line "$table = $modx->getFullTableName(’modx_web_user_attributes’);" it parsed without serious alert (I compared it with webloginpe.class.php) but returned no output.
          • 7155
          • 160 Posts
          oops sorry, yes I should’ve excluded modx_

          It may not work inside your WebLoginPE template.

          What is your WebLoginPE call?
            • 21800
            • 174 Posts
            At this time I use the simple "[[GetEmail? &userid=`[+view.internalKey+]`]]". and I’ve made it unchached "[!GetEmail? &userid=`[+view.internalKey+]`!]".

            Next I want to insert this call into an eForm call as the "to" parameter.
              • 7155
              • 160 Posts
              So its working then?
                • 21800
                • 174 Posts
                No output at all.
                  • 21800
                  • 174 Posts
                  [+view.internalKey+] has a propper value.
                    • 21800
                    • 174 Posts
                    Now it works, it was my fault reformatting the code. :-( I’m very sorry.
                    Thanx again, designetic.
                      • 7155
                      • 160 Posts
                      no prob. smiley glad to have helped