Merge Lists

Dilbert

Member
I currently have 5 mailing list subjects each with a separate list for each day of the week.
A user might (now) sign of for Monday - Friday (5 lists), but the page to sign up looks awful.
https://www.pathlabtalk.com/forum/index.php?/newsletters

Since there is no way to build a nice form for the users to sign up for all of the lists they want at one time, I am going to merge the subject together and no longer give them the option of selecting daily lists from each subject.

How can I merge 5 lists into one and make sure there are no duplicates?

Thanks
 
wow, your newsletter page sure looks complicated and would 100% stop people from joining it. Its 22:28pm here in the UK, let me create something a lot better for you in PHP. Ill get back to you tomorrow at some point.
 
Why not just use the old version but just export them from there and import them into MailWizz?
I no longer have the old version of the software. It did not run on PHP 7, and the author seemed to have abandoned it.

Do you think there's a way to accomplish the same thing with this software? Signing up for multiple lists seems to be impossible.

Thanks
 
I havent managed to look into it yet as been a bit busy today with other tasks. Will try get something in the next few days for you.
 
Can someone help with this?
Ideally I'd like to maintain the separate lists, but clearly no one will sign up for them with the way it's designed.
A built in form for signing up would really be helpful
 
@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.
 

Attachments

  • subscribe-multiple-lists.zip
    791.4 KB · Views: 19
Wow, looks like you put a lot into this.

I suspect I've done something wrong.

I created the api keys and edited the index.php file. I edited the api URL to https://www.MySite.net/newsletter/newsletter/api and uploaded the folder to https://www.MySite.net/newsletter/newsletter/api/subscribe-multiple-lists
I then visited https://www.MySite.net/newsletter/newsletter/api/subscribe-multiple-lists/index.php and the form displays. I put in my email and selected a list but it opens in a new page showing the blank form and does not subscribe me.

Could you offer some guidance as to where I went wrong?

Thanks so much!
 
The main issue is that you load the page over https while the resources inside:
Code:
<meta http-equiv="content-type" content="text/html" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" />
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Noto+Sans:700italic" />
<link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/bootstrap-glyphicons.css" />
<link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/style.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.mailwizz.com/backend/assets/js/bootstrap.js" id="script-bootstrap"></script>
<link rel="shortcut icon" href="http://www.mailwizz.com/favicon.ico" type="image/x-icon" />
Are loaded via http. Make sure the above are loaded from https as well.

Or access the page at http://www.pathlabtalk.net/newsletter/api/subscribe-multiple-lists/index.php and you'll the the page looking and acting right ;)
 
Doh, thanks!

I just tested it out. It seems that users aren't added to the list(s).

Also, it didn't send the confirmation email.
 
@Dilbert - Can you post here the index.php (hide ONLY the api keys from it when posting) and put it into a [ code ][ /code ] block when posting it into the forums.
 
I only edited where you suggested.

And THANK YOU very much for doing this for me.

Code:
<?php

require dirname(__FILE__) . '/vendor/autoload.php';

$config = new MailWizzApi_Config(array(
    'apiUrl'     => 'https://www.pathlabtalk.net/newsletter/api',
    'publicKey'  => 'e9e421c1d09142691e0706679726c30e5c71a81c',
    'privateKey' => '3a3c42bbe2b4dfda6bb0e02c2031c7a1335ca295',
));

// now inject the configuration and we are ready to make api calls
MailWizzApi_Base::setConfig($config);

// see if the request is made via ajax.
$isAjaxRequest = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';

// and if it is and we have post values, then we can proceed in sending the subscriber.
if ($isAjaxRequest && !empty($_POST)) {

    $lists = isset($_POST['lists']) ? (array)$_POST['lists'] : array();
    foreach ( $lists as $list ) {
        $endpoint = new MailWizzApi_Endpoint_ListSubscribers();
        $response = $endpoint->create($list, array(
            'EMAIL' => isset($_POST['EMAIL']) ? $_POST['EMAIL'] : null,
            'FNAME' => isset($_POST['FNAME']) ? $_POST['FNAME'] : null,
            'LNAME' => isset($_POST['LNAME']) ? $_POST['LNAME'] : null,
        ));
    }

    exit(MailWizzApi_Json::encode(array(
        'status'    => 'success',
        'message'   => 'Thank you for joining our email list. Please confirm your email address now!'
    )));
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html" />
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans" />
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Noto+Sans:700italic" />
    <link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/bootstrap-glyphicons.css" />
    <link rel="stylesheet" type="text/css" href="http://www.mailwizz.com/backend/assets/css/style.css" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="http://www.mailwizz.com/backend/assets/js/bootstrap.js" id="script-bootstrap"></script>
    <link rel="shortcut icon" href="http://www.mailwizz.com/favicon.ico" type="image/x-icon" />
    <title>Ajax subscribe</title>
    <style>
    #content {
        margin-top: 30px;
        border: 1px solid #c2c2c2;
        padding:10px;
    }
    div.error {
        border: 1px solid #b94a48;
        background: #f2dede;
        color: #000000;
        font-size: 12px;
        padding:10px;
        margin-bottom:10px;
    }
    div.success {
        color: #000000;
        background: #dff0d8;
        border: 1px solid #d6e9c6;
        font-size: 12px;
        padding:10px;
        margin-bottom:10px;
    }
    input.error {
        border: 1px solid #b94a48;
        background: #f2dede;
        font-size: 12px;
    }
    </style>
    <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 dinamically 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>
</head>

<body>

<div class="col-lg-4"><!-- --></div>

<div class="col-lg-4" id="content">
    <!--
    The form below is generated by MailWizz EMA.
    You can see your list forms by viewing the "Embed forms" section of your email list.
    -->
    <div class="message"></div>
    <form action="" method="post" accept-charset="utf-8" target="_blank">

        <div class="form-group">
            <label>Email <span class="required">*</span></label>
            <input type="text" class="form-control" name="EMAIL" placeholder="" value="" required />
        </div>

        <div class="form-group">
            <label>First name</label>
            <input type="text" class="form-control" name="FNAME" placeholder="" value=""/>
        </div>

        <div class="form-group">
            <label>Last name</label>
            <input type="text" class="form-control" name="LNAME" placeholder="" value=""/>
        </div>

        <div class="form-group">
            <label>Lists (ctrl + click / cmd + click to select multiple lists) </label>
            <select multiple name="lists" class="form-control">
                <option value="key"> List 1 </option>
                <option value="key"> List 2 </option>
                <option value="key"> List 3 </option>
                <option value="key"> List 4 </option>
                <option value="key"> List 5 </option>
            </select>
        </div>

        <div class="clearfix"><!-- --></div>
        <div class="actions">
            <button type="submit" class="btn btn-default btn-submit" data-loading-text="Please wait...">Subscribe</button>
        </div>
        <div class="clearfix"><!-- --></div>

    </form>
</div>

<div class="col-lg-4"><!-- --></div>

</body>
</html>
 
Partial success. I didn't get the confirm email, and regardless of how many lists I select, only one list ends ends signed up for. If I signed up for each list individually, it worked, but selecting more than one at a time does not.
 
Ah, right, please make this change, instead of:
Code:
<select multiple name="lists" class="form-control">
It should be
Code:
<select multiple name="lists[]" class="form-control">
:D
 
That worked, just waiting to see if I get the confirm email. I see you subscribed to one, did it send the confirm to you?
 
Back
Top