Merge Lists

Dilbert

Member
Hmm, that's odd. No matter what email address I use (I have a bunch), I'm not getting the confirm emails. One was my work email, we block tons of stuff, so probably blocked. The other was a gmail, that might have been blocked too.

I just tried another address with another client and it worked!

Will I be able to use this type of list with what you built? https://www.pathlabtalk.com/forum/index.php?/newsletter.html/

Again, thank you so much!
 

twisted1919

Administrator
Staff member

frm.mwz

Well-Known Member
@Dilbert - I have attached an example form that would use ajax to subscribe to 5 different lists at once.
Unzip and upload the folder on your server, then open index.php and look for:
PHP:
$config = new MailWizzApi_Config(array(
    'apiUrl'     => 'http://www.mailwizz-powered-website.tld/api',
    'publicKey'  => 'PUBLIC-KEY',
    'privateKey' => 'PRIVATE-KEY',
));
And replace with your own info.

And also find:
Code:
<option value="cr105po1w3d1d"> List 1 </option>
                <option value="cr105po1w3d2d"> List 2 </option>
                <option value="cr105po1w3d3d"> List 3 </option>
                <option value="cr105po1w3d4d"> List 4 </option>
                <option value="cr105po1w3d5d"> List 5 </option>
And replace the list uids from here with your own list uids.

Then you can try it and you'll see how you get subscribed to all the lists you select.
Perhaps not a top priority to make this a feature within the app to allow the user to select which lists to display at the forms ;)
 

Dilbert

Member
I almost have my page done, it really is awesome now that I can subscribe to multiple lists again!

I set the page up with checkboxes. I have tried many different ways to get it to require art least one, but I can't. I think it's conflicting with the error checking that already happening.

Any chance I could ask an additional favor? Can you look at my checkboxes and make the code require at least one? They will all be named lists[].

I attached your error script, I tried to attach the whole page, but I got an error for too many characters.

Code:
<script>
    jQuery(document).ready(function($){
        // bootstrap button
        $('.btn-submit').button();

        $('#content form').on('submit', function(e){
            e.preventDefault();
            var $this = $(this);
            var $message = $('.message');
            var $email = $('input[name=EMAIL]', this);

            // empty any previous message
            $message.empty().removeClass('error').removeClass('success').hide();

            // remove dynamically attached error elements
            $('.error', $this).remove();

            // just a small check, the api server will check anyway
            var email = $email.val();
            if (!email || email.indexOf('@') < 0) {
                $message.addClass('error').text('Please enter a valid email!').show();
                return false;
            }

            // show the loading text on the submit button
            $('.btn-submit').button('loading');

            // post the form to the php script and get the response
            $.post('', $this.serialize(), function(json){
                $('.btn-submit').button('reset');
                $message.text(json.message).show();

                // if the status is success, add the success class.
                if (json.status == 'success') {
                    $message.addClass('success');
                    // also, empty the fields
                    $('input[type=text]', $this).val('');
                } else {
                    // otherwise, add the error class.
                    $message.addClass('error');
                }
            }, 'json');

            return false;
        });
    });
    </script>
 

twisted1919

Administrator
Staff member
Sure thing, there you go:
Code:
<script>
   jQuery(document).ready(function($){
       // bootstrap button
       $('.btn-submit').button();

       $('#content form').on('submit', function(e){
           e.preventDefault();
           var $this = $(this);
           var $message = $('.message');
           var $email = $('input[name=EMAIL]', this);

           // empty any previous message
           $message.empty().removeClass('error').removeClass('success').hide();

           // remove dynamically attached error elements
           $('.error', $this).remove();

           // just a small check, the api server will check anyway
           var email = $email.val();
           if (!email || email.indexOf('@') < 0) {
               $message.addClass('error').text('Please enter a valid email!').show();
               return false;
           }

          // new check, make sure at least one list is checked:
          if ( ! $('input[name="lists[]"]:checked').length ) {
               $message.addClass('error').text('Please select at least one list!').show();
               return false;
          }

           // show the loading text on the submit button
           $('.btn-submit').button('loading');

           // post the form to the php script and get the response
           $.post('', $this.serialize(), function(json){
               $('.btn-submit').button('reset');
               $message.text(json.message).show();

               // if the status is success, add the success class.
               if (json.status == 'success') {
                   $message.addClass('success');
                   // also, empty the fields
                   $('input[type=text]', $this).val('');
               } else {
                   // otherwise, add the error class.
                   $message.addClass('error');
               }
           }, 'json');

           return false;
       });
   });
   </script>
 

twisted1919

Administrator
Staff member
p.s: the page assets that you load now from mailwizz.com, better download them locally and load them from your site ;)
 

Dilbert

Member
p.s: the page assets that you load now from mailwizz.com, better download them locally and load them from your site ;)
Thank you very much for the updated script!

And yes, I was planning on downloading everything I can to my site before making it live. It seems there might be items I don't need too like the glyphicons. Not sure I'm using it.

I'll post my final page later, your critique would be appreciated.
 

laurentiu

Well-Known Member
Staff member Support Staff MailWizz 2.0 Tester
@Dima108 - your URL is in customer area -> api keys -> on the right is a info button you need to press it and there you see the URL.
Info button contain useful information and is present almost everywhere.
 

laurentiu

Well-Known Member
Staff member Support Staff MailWizz 2.0 Tester
Uh oh, new problem?
I am using [UNSUBSCRIBE_LINK], is it supposed to be UNSUBSCRIBE_URL?
Do I need the [ ] brackets?
You can use [UNSUBSCRIBE_FROM_CUSTOMER_LINK] is the same as [UNSUBSCRIBE_LINK] but this will unsubscribe subscribers from all the customer lists.
 
Top