How to add or update subscriber through form

Britt Malka

Member
Hi,
With my old autoresponder system, I just added the form to the payment processor, and if it was a new customer, he was added. If it was an existing customer, his data was updated with the field I used for the product he bought.

This doesn't work with Mailwizz. If a subscriber exists, the fields aren't updated.

How can I make a form that adds new customers and updates existing ones?

This is an example of the form I tried, but it didn't work as expected (I had my real domain name there):

HTML:
<form action="http://DOMAIN.com/index.php/lists/rp577273cf8aa/subscribe" method="post" accept-charset="utf-8" target="_blank">
<input type="text" name="EMAIL" placeholder="email" value="" required />
<input type="text" name="PARTRIDGE" placeholder="" value="Partridge" />
<input type="text" name="FNAME" placeholder="fname" value=""/>
<input type="text" name="LNAME" placeholder="lname" value=""/>
<button type="submit">Subscribe</button>
</form>
 
his doesn't work with Mailwizz. If a subscriber exists, the fields aren't updated.
Yeah, this is correct, we have the update profile page for such things.

Why not use the API for this? I attached a nice example for you, unzip it and upload it in your server, let's say it will be accessible at
http://www.domain.com/custom/list-subscribe/
Open the index.php file inside, and look for:
PHP:
// START EDIT
$domainWhereMailwizzIsInstalled = 'http://www.domain.com';
$publicApiKEy  = 'ENTER YOUR KEY HERE';
$privateApiKey = 'ENTER YOUR KEY HERE';
// END EDIT
Now replace the above values with the real ones. Go to Customer area, and click the API KEYS section and generate new keys and use them here. Instead of 'http://www.domain.com' use your own domain.

Now, edit your form and make it like:
Code:
<form action="http://www.domain.com/custom/list-subscribe/" method="post" accept-charset="utf-8" target="_blank">
<input type="hidden" name="list" value="rp577273cf8aa" />
<input type="text" name="EMAIL" placeholder="email" value="" required />
<input type="text" name="PARTRIDGE" placeholder="" value="Partridge" />
<input type="text" name="FNAME" placeholder="fname" value=""/>
<input type="text" name="LNAME" placeholder="lname" value=""/>
<button type="submit">Subscribe</button>
</form>

When this form will be submitted, the data will be sent at http://www.domain.com/custom/list-subscribe/ which is the files i gave you. That will in turn call the API which will say if the email is taken in the list or not and it will create/update it properly, then it will redirect the subscriber to the right update page.
 

Attachments

When I use the form with a new subscriber, the first time it gives me a 404 error. Then if I use my browser's back button and submit again, it works.

I'll add the error log below.

Could this be because we're not on a VPS yet? (Will be, soon) Our cron jobs can max run every 15 minutes right now.

Code:
2017/11/24 03:44:59 [error] [exception.CHttpException.404] [79.176.33.53] exception 'CHttpException' with message 'The system is unable to find the requested action "update-profile".' in /home/DOMAIN/public_html/voopti.com/apps/common/framework/web/CController.php:486
Stack trace:
#0 /home/DOMAIN/public_html/voopti.com/apps/common/framework/web/CController.php(270): CController->missingAction('update-profile')
#1 /home/DOMAIN/public_html/voopti.com/apps/common/framework/web/CWebApplication.php(282): CController->run('update-profile')
#2 /home/DOMAIN/public_html/voopti.com/apps/common/framework/web/CWebApplication.php(141): CWebApplication->runController('lists/update-pr...')
#3 /home/DOMAIN/public_html/voopti.com/apps/common/framework/base/CApplication.php(185): CWebApplication->processRequest()
#4 /home/DOMAIN/public_html/voopti.com/apps/init.php(238): CApplication->run()
#5 /home/DOMAIN/public_html/voopti.com/index.php(18): require_once('/home/DOMAIN...')
#6 {main}
REQUEST_URI=/index.php/lists/cr589l82pea69/update-profile/
HTTP_REFERER=http://malka.space/looks/
 
@Britt Malka - open index.php from the file i gave you and make line 44:
from
PHP:
$url = $domainWhereMailwizzIsInstalled . '/index.php/lists/' . $list . '/update-profile/' . $bodyData['subscriber_uid'];
to
PHP:
$url = $domainWhereMailwizzIsInstalled . '/index.php/lists/' . $list . '/update-profile/' . $bodyData['record']['subscriber_uid'];
 
This is great @twisted1919 , do you think it could be made the default (or an option)?
Maybe even @corey34 's recent question re various signup sources to be recorded in custom fields could be address by that similarly?
 
This is great @twisted1919 , do you think it could be made the default (or an option)?
It would cause issues if we do this by default. Other people could then update the info of other people just knowing the email address and this isn't acceptable. We have the api and it can be done with the api in a few lines of code, so that is acceptable to me ;)

Maybe even @corey34 's recent question re various signup sources to be recorded in custom fields could be address by that similarly?
I don't know what this is about, but i will have a look.
 
It would cause issues if we do this by default. Other people could then update the info of other people just knowing the email address and this isn't acceptable. We have the api and it can be done with the api in a few lines of code, so that is acceptable to me ;).
Hello! I posted a subscription form on my website. When I enter an email that already exists in the list, the profile update page opens on the site where mailwizz is installed. How to disable this redirection to update the profile?

P.S. Sorry for my bad english!)
 
@ramts - this is actually the way this works and cannot be changed for now :-s

But it turns out that the one who knows my email can go to my profile and learn my personal data from the form fields that I add to the form.

It is unacceptable! how can you then add access to the profile by password?
 
You can go to your email list and enter a redirect url for when a subscriber exists already at subscription time:
Screenshot 2018-01-04 21.44.39.png
 
You can do it from .htaccess if you wish, deny access to any url that contains /update-profile/ in it.
You'll have to search on how to do this thoiugh.
 
Maybe something like this in .htaccess (didn't tested it) :
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/lists\/([a-z0-9]{13})\/update\-profile\/([a-z0-9]{13})$ [NC]
RewriteRule ^.*$ - [F,L]
 
You can do it from .htaccess if you wish, deny access to any url that contains /update-profile/ in it.
You'll have to search on how to do this thoiugh.
Perhaps this is the solution to the problem. I'll think about it. Thanks a lot for your help!
 
Back
Top