We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27
    • 117 Posts
    Hi all

    Anyone that has read my previous posts will know I’m not great at code undecided - hence my question:

    I have created a web group called ’Newsletter’ and would like to tweak my WebSignup snippet form (parameter: &groups=`Registered Users`) so that the last question is ’Check here to ALSO join Newsletter group’.

    How do I script a checkbox so that if they want to join Newsletters too, modx knows to add them to multiple groups?

    Help, advice, guesses, all gratefully accepted.

    Cheers, 0
      • 26471
      • 17 Posts
      Which version of WebSignup are you using?

      I have version 1.1 here and I would do the following:

      1. Modify the WebSignup chunk to include a checkbox in the form, with a name like "join_newsletter"
      2. Modify the WebSignup snippet to add a few lines after the following code:

      # setup web groups
      $groups = isset($groups) ? explode(',',$groups):array();
      for($i=0;$i<count($groups);$i++) $groups[$i] = trim($groups[$i]);


      additional code:

      if (isset($join_newsletter)) {
         $groups[] = 'Newsletter';
      }

        • 27
        • 117 Posts
        thanks for that SD, is there anything else i need to add? doing what you said doesn’t work for me here.

        im on websignup 1.1 as well

        cheers

        0
          • 26471
          • 17 Posts
          Sorry, I made a mistake. Please try this instead:
          if (isset($_POST['join_newsletter'])) {
             $groups[] = 'Newsletter';
          }
            • 27
            • 117 Posts
            That works perfect! thanks a million SD!

            I’ve ordered "learn php in 24hrs" =)

            Nuff respect

            0
            • There are so many great PHP tutorials available that I haven’t bought any books for years.

              From the horse’s mouth, as it were... http://devzone.zend.com/public/view/tag/tutorials

              Another of my favorites... http://www.onlamp.com/php/

                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
                • 27
                • 117 Posts
                I love this forum =)