We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25636
    • 21 Posts
    How do you let the user select from a list of specified recipients?
      Linux 2.6.32.8-grsec-2.1.14-modsign-xeon-64, PHP 5.2.14, MySQL 5.0.51a(client) 5.1.39-log (server), --with-pdo-mysql, Firefox/3.6.12
      • 25636
      • 21 Posts
      I figure I could put all the email addresses in a select drop down menu and then use the corresponding placeholder in the FormIt emailTo parameter. (similar to http://modxcms.com/forums/index.php/topic,52334.msg307845.html#msg307845). But this still doesn’t obfuscate emails.

      Do I have to write a custom hook for this?
        Linux 2.6.32.8-grsec-2.1.14-modsign-xeon-64, PHP 5.2.14, MySQL 5.0.51a(client) 5.1.39-log (server), --with-pdo-mysql, Firefox/3.6.12
        • 18988
        • 3 Posts
        Hi,

        I’m not sure it’s the best solution, but here is how I solved this :


        Inside HTML Form
        <select name="service">
          <option value="0">Please choose...</option>
          <option value="1">Group number 1</option>
          <option value="2">Group number 2</option>
          <option value="3">Group number 3</option>
        </select>
        


        Snippet called ’groupSelector’
        <?php
          $group[0] = '[email protected]'; // Default group (no choice)
          $group[1] = '[email protected],[email protected]'; // Group number 1 option
          $group[2] = '[email protected]'; // Group number 2 option
          $group[3] = '[email protected]'; // Group number 3 option
        
        $userChoice = $hook->getValue('service');
        $hook->setValue('emailAddresses',$group[$userChoice]);
        return true;
        ?>
        


        ... called the snippet
        [[!FormIt? &emailTo=`[[+emailAddresses]]` &hooks=`groupSelector,spam,email,formItToDb` ... ]]  


        Well, if you agree with me, this would be my 1st contribution ! smiley hope this helps !

        Vincent

        (works with ModX Revo + formIt 1.4.0 pl)

          • 25636
          • 21 Posts
          Vincent,

          Thanks man. This looks like the solution. I’ll give this a go. Thanks again (I was beginning to think the lack of replies implied the solution didn’t require a custom hook).
            Linux 2.6.32.8-grsec-2.1.14-modsign-xeon-64, PHP 5.2.14, MySQL 5.0.51a(client) 5.1.39-log (server), --with-pdo-mysql, Firefox/3.6.12
            • 23889
            • 11 Posts
            Hello

            I have same problem.bt little bit different...I have to select email address according to zip code of city...i.e.Zip code will be given in different text box and according to i have to send email to particular person.

            plz Reply..

            Thanks,
            Priyanka
              • 25636
              • 21 Posts
              Priyanka, you can use the same solution that Vincent offered.

              If there are only a few zip codes from which to choose, you can list them in a select box. If you have many zip codes and listing them all becomes impractical, you’d still have to create an array of zip code keys to email address values, process the user’s input to remove white spaces, and unify capitalization etc, and return the correct value based on the user’s processed key.
                Linux 2.6.32.8-grsec-2.1.14-modsign-xeon-64, PHP 5.2.14, MySQL 5.0.51a(client) 5.1.39-log (server), --with-pdo-mysql, Firefox/3.6.12
                • 23889
                • 11 Posts
                Hello

                Thanks for reply
                I have to select email address according to zip code from database..Can i assign multiple values to email address???with setvalue???

                $userChoice = $hook->getValue(’zip’);

                global $modx;
                $sql = ("select ’email’ from `dealer` where `zip` = ’".$userChoice."’");
                $result = $modx->db->query($sql);

                if( $result != ’Null’ )
                {
                $hook->setValue(’emailAddresses’,$result);
                }



                return true;


                I am using this code bt its not working
                  • 25636
                  • 21 Posts
                  Hi Priyanka,

                  I don’t have much experience with custom db queries.

                  All I can recommend is to try running through the xPDO tutorials, the links to which splittingred has listed already.
                    Linux 2.6.32.8-grsec-2.1.14-modsign-xeon-64, PHP 5.2.14, MySQL 5.0.51a(client) 5.1.39-log (server), --with-pdo-mysql, Firefox/3.6.12