aelvan / mailchimp-subscribe-craft Goto Github PK
View Code? Open in Web Editor NEWThis plugin has retired!
License: MIT License
This plugin has retired!
License: MIT License
I just installed this on a site running Craft 2.5.2762 and I get the following error:
Parse error: syntax error, unexpected '[', expecting ')' in /Users/username/Sites/sitename.dev/craft/plugins/mailchimpsubscribe/vendor/guzzlehttp/promises/src/functions.php on line 41
The README does not imply that you need to use dataType: 'json'
when sending AJAX requests.
However the response will be the HTML of the page unless dataType: 'json'
is added to the $.ajax query
I'm having an issue with the multilist subscription.
Everything is fine up until the foreach statement:
foreach ($listIdArr as $listId) {
$retval = $api->listSubscribe($listId, $email, $vars);
}
print_r($listIdArr) before it reveals an array created from the piped string which is correct. However the above only seems to subscribe the user to the last list in the array? Any ideas or how to fix?
Cheers
Quick Edit on this. It seems the problem only occurs if the FNAME or LNAME variables are empty.
Hi, I have the exact same problem as issue #27. But it's on line 66.
I have the newest version of the plugin. PHP 7. The fix is already applied, but I get the exact same error.
I took the examples from the docs to check if a user already exists.
So I've changed line 66 from
if ($redirect != '' && $result->success) {
to
if ($redirect != '' && $result['success']) {
The error message is gone...
Now I have to find out why it redirects although it's an ajax request...
array_push() expects parameter 1 to be array, object given
try { $results = $mc->request('lists/' . $listId . '/members/' . md5(strtolower($email)), $postVars, 'PUT'); array_push($results, $this->_getMessage(200, $email, $vars, Craft::t("Subscribed successfully"), true)); } catch (\Exception $e) { // an error occured $msg = json_decode($e->getMessage()); array_push($results, $this->_getMessage($msg->status, $email, $vars, Craft::t($msg->title))); }
in the try part i got an error array required object given in array push
Hi,
Mailchimp has now made setting the dedicated GDPR fields through the API. (Better late than never!)
Is this something that can be added?
The API shows that you need to pass your GDPR options as an array like so
'marketing_permissions' => [
['marketing_permission_id' =>'listId','enabled' => true/false],
['marketing_permission_id' =>'listId','enabled' => true/false],
['marketing_permission_id' =>'listId','enabled' => true/false}
]
Whereby each one represents a different GDPR list. Would be great if the plugin could pull out any $vars
set to marketing_permissions
and set them accordingly. π
Is there anyway you could add the ability to unsubscribe a user from a list? We're wanting to add a "Marketing preferences" section to our frontend user section which will let people opt in or out of our mailchimp list.
Submitting the following form results in a 404 error:
<form class="ContactForm" action="" method="POST">
{{ csrfInput() }}
<input type="hidden" name="action" value="mailchimp-subscribe/list/Subscribe">
<!-- ... -->
<input type="submit" name="" value="Subscribe"/>
</form>
HTTP 404 β Not Found β yii\web\NotFoundHttpException
Page not found.
Caused by: Invalid Route β yii\base\InvalidRouteException
Unable to resolve the request "mailchimp-subscribe/list/Subscribe".
I am assuming the value in the the hidden input is incorrect β but can't seem to find the correct value. Any help would be appreciated!
I have the correct api details and list id, goes to 500 error?
Hi AndrΓ©.
Thank you for this great plugin.
I am using V0.4 and I tried to update to V1.4 but it does not work with the new version (it works locally but not on my server).
I checked in the logs but nothing.
Where should I tried to look at ?
I've just installed the plugin on Craft 3.0.28, and have copied the example form template from Example Usage. (Have also created an index.twig template at /newsletter/receipt for the confirmation message.)
On submitting the form I get:
Page not found.β΅
Caused by: Invalid Route β yii\base\InvalidRouteException
Unable to resolve the request "mailchimp-subscribe/list/subscribe".
in /Users/jamesgreig/Repos/hunts/vendor/yiisoft/yii2/base/Module.php at line 537
Form template is...
<form class="newsletter-form" action="" method="POST">
{{ csrfInput() }}
<input type="hidden" name="action" value="mailchimp-subscribe/list/subscribe">
<input type="hidden" name="redirect" value="{{ 'newsletter/receipt' | hash }}">
{% if mailchimpSubscribe is defined %}
{% if (not mailchimpSubscribe.success) and (mailchimpSubscribe.errorCode!='1000') %}
<p>An error occured. Please try again.</p>
{% endif %}
{% endif %}
<div class="field-line">
<label{% if (mailchimpSubscribe is defined) and (mailchimpSubscribe.errorCode=='1000') %} class="error"{% endif %}>Email:</label>
<input type="text" name="email" value="{% if (mailchimpSubscribe is defined) and (not mailchimpSubscribe.success) %}{{ mailchimpSubscribe.values.email }}{% endif %}"/>
</div>
<input type="submit" name="" value="Subscribe"/>
</form>
Hi, I tried to install this plugin in Craft 2.3.2632 Unzipped and put the folder "mailchimp-subscribe-craft-master" in the folder plugins. Then, in Craft, clicked on "Plugins". The mailchimp subscribe plugin is not recognized. Other plugins installed without any problem. Any ideas ?
Rudolph
I think there are a bunch of errors relating to the recent update of the plugin.
I had version 0.4 installed and it worked much better than the new one...
This example does not seem to work:
https://github.com/aelvan/mailchimp-subscribe-craft#ajax-submitting
It always outputs "WEEEEEEEEE"...
Before the update it worked like a charm and was submitting the correct error codes! E.G. Also the codes that a user was already subscribed.
Now it's all WEEEEEEEEE but does not work :(
Is there a way to check if an email is on a list without having to click the Check if subscribed
button as per the example form documented at https://github.com/aelvan/mailchimp-subscribe-craft/tree/master#checking-if-an-email-is-already-on-a-list?
I noticed that the Craft 3 version has this alternative:
{% set checkResponse = craft.mailchimpSubscribe.checkIfSubscribed('[email protected]', 'mylistid') %}
{% if checkResponse.success %}
Email is on list!
{% else %}
Email is NOT on list!
{% endif %}
Would the above be possible in the Craft 2.x version? If not, could you suggest any workarounds?
The actionUnubscribe() should be;
actionUnsubscribe()
(line 83 in \src\controllers\ListController.php)
Same function is missing the $redirect variable;
$redirect = $request->getParam('redirect', '');
(line ~91 in \src\controllers\ListController.php).
Suddenly, the plugin is not working on Craft 2 anymore. I downloaded the craft 2 version in the master branch, but still can't make it work. There are no errors, it's sending the proper success response but I just don't receive the opt-in mailchimp email.
Anyone have an idea?
I am trying to submit the newsletter signup details with an AJAX request, my request looks like this:
And I am receiving this response:
Have I done something wrong in my setup? The plugin seems to have installed fine, also if I disable the plugin I get a different 404 error returned, just a bog standard PHP / nginx error page, so it seems to be matching at least part of the route? Bit of a newbie with Craft sorry!
Thanks for any help
I would like to allow registered users who are logged in to add themselves to Groups as per checkboxes in form documented at https://github.com/aelvan/mailchimp-subscribe-craft/tree/master#groups. However, I don't want them to have to fill out these three fields.
Is there a way to populate these field with {{ currentUser.firstName }}
, {{ currentUser.lastName }}
, and {{ currentUser.email }}
respectively?
I am currently using the craft 2 version of this plugin and we are upgrading the server to php7. However the plugin breaks with the following error message:
Methods with the same name as their class will not be constructors in a future version of PHP; MCAPI has a deprecated constructor
I had a play around with the plugin to see if changing the function name or class name would have any effect but it through another error saying it could not connect.
So my question is do you have an archived craft 2 version with a fix in it for php 7 as we won't be switching to craft 3 just yet.
Cheers
Im trying to integrate this plug in as basic as possible and its not working. Im just getting a "An error occured. Please try again." error.
I used the 2nd example from your ready file.
I wonder if it's an issue with Craft 2.5
....so that one can not show the 'do you want to subscribe to our newsletter' if they already are.
Anything to keep that checkout flow (with Commerce) - as smooth as possible!
Not sure if this is due to an update to MailChimps API as I'm sure this was working when I last tested a couple of months ago;
<form method="post" accept-charset="UTF-8">
{{ csrfInput() }}
<input type="hidden" name="email" value="{{ currentUser.email }}">
<input type="hidden" name="action" value="mailchimp-subscribe/list/unsubscribe">
<button type="submit">Unsubscribe</button>
</form>
I get the following error;
The subscribe action works fine, which suggests it's not a problem with the config etc.
Hey, you closed the issue before I could respond with this error I am getting with your suggestion.
Neither the property "mcsubApikey" nor one of the methods "mcsubApikey()", "getmcsubApikey()"/"ismcsubApikey()" or "__call()" exist and have public access in class "Craft\ConfigVariable".
Installed v1.0.0 and tried to subscribe using the example template but I got an error of "Mailchimp\Mailchip class was not found"
Perhaps the "pacely/mailchimp-apiv3" package needs to be installed through composer.
I've installed the plugin as described and am using the example form but only get a 404 after posting the form. Is this plugin still up to date and working? Thanks.
Hi,
I don't see a LICENSE
or COPYING
file in the project and I don't see any mention of a license in the readme or the plugin file. Which license is this project supposed to be distributed under?
Could you please provide some clarification and add either file mentioned?
Thanks in advance.
Hi, Thanks for the plugin, it works great but so far I cant figure out how to get it to work with radio button fields, I've set them up on the Mailchimp side of things, I have tried giving all the fields the same name, and I have tried adding numbers to them e.g. name="mcvars[FIELD-1]" or name="mcvars[FIELD[0]]" but so far no luck.
Example of my fields:
<input type="radio" name="mcvars[FIELD]" id="FIELD-0" value="Value 1"><label for="FIELD-0">Value 1</label>
<input type="radio" name="mcvars[FIELD]" id="FIELD-1" value="Value 2"><label for="FIELD-1">Value 2</label>
Is it possible to do this? Or to have fields that add the user into a group using checkboxes?
Thanks,
I'm having a hard time getting this plugin to work, using the example code.
I'm on craft 2.6.3000, and using the master branch of the plugin.
<form class="newsletter-form" id="newsletter-form" action="" method="POST">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="mailchimpSubscribe/list/Subscribe">
<input type="hidden" name="redirect" value="{{siteUrl}}#newsletter-form">
{% if mailchimpSubscribe is defined %}
<p>{{mailchimpSubscribe.errorCode}} - {{mailchimpSubscribe.message}}</p>
{% endif %}
<div class="field-line">
<label{% if (mailchimpSubscribe is defined) and (mailchimpSubscribe.errorCode=='1000') %} class="error"{% endif %}>Email:</label>
<input type="text" name="email" value="{% if (mailchimpSubscribe is defined) and (not mailchimpSubscribe.success) %}{{ mailchimpSubscribe.values.email }}{% endif %}"/>
</div>
<input type="submit" name="" value="Subscribe"/>
</form>
When submitting the empty form or an invalid email, I'm getting errorCode 1000
and message Invalid email
(as it should).
When submitting the form with a valid email, I'm getting errorCode 404
and message Resource Not Found
.
On a side note, I would like to scroll the page to the form after submitting, since the form is located at the bottom of the homepage, hence the <input type="hidden" name="redirect" value="{{siteUrl}}#newsletter-form">
. As the redirect is only supposed to work when having a successful subscription, how can I have the correct scrollposition when having an error?
In releases.json there is a:
"version": "1.0.4",
But on github you did not create a new release:
https://github.com/aelvan/mailchimp-subscribe-craft/releases
Hi, When submitting a form request an error is thrown:
MailchimpSubscribe_ListController : line 39
$result->success
($result is an array) $result['success'] works correctly.
Hopefully resolved #23
Not a huge deal, but I thought it might save someone some troubleshooting. In the main example you have:
value="{{ newsletter/receipt | hash }}"
For the redirect. It looks like though that the hash filter takes a string. At least this was erroring for me, and this worked:
value="{{ 'newsletter/receipt' | hash }}"
Thank you so much for this awesome tool!
Hi,
I'm having trouble adding Groups.
I've made a group in mailchimp that has some choises (radio buttons).
For some reason it gives me a error (Invalid Resources).
My input field for a single radio button looks like this:
<input type="radio" name="mcvars[group][4973]['First Choice']" value="First Choice">
Here is 4973 my from id and "First Choise" one of the options.
Could u guys tell me what I'm doing wrong? Maybe add some more documentation about using Groups?
Would be good to have a service so that we can include this in other plugins.
MCAPI is no longer used, should be removed.
I have this common problem that MailChimp doesn't send email confirmation (ex.: double opt-in) regarding the user language. So, to get around this problem, I must create a mailing list by language and set the "lid" field with a custom variable in the settings.
I was wondering if this could be an appropriate feature to display one mailing list ID field for each site locale in the control panel if the site is localized ? See the image attached.
Thanks !
I cannot install the plugin via shell using composer require aelvan/mailchimp-subscribe
:
Using version ^2.0 for aelvan/mailchimp-subscribe
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for aelvan/mailchimp-subscribe ^2.0 -> satisfiable by aelvan/mailchimp-subscribe[2.0.0].
- aelvan/mailchimp-subscribe 2.0.0 requires pacely/mailchimp-apiv3 dev-master -> satisfiable by pacely/mailchimp-apiv3[dev-master] but these conflict with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.
I'm on Craft 3 RC5.
What am I doing wrong? Thanks in advance.
So I think it's because in ListController.php, this line:
if ($request->getAcceptsJson()) {
return $this->asJson($result);
}
will not validate if using the default $.post without specifying the datatype.
Using this:
$.ajax({url: '/', type:"POST", data: $(this).serialize(), dataType:"json",success: function (data) {
if (!data.success) {
// there was an error, do something with data
} else {
// Success
}
}})
it works.
I was testing a new list with my primary email and deleted it to resubscribe and test changes. Everything looked successful on the front-end, but I never received another double opt-in email, nor did my list ever add my email back to the list of the subscribers.
After further testing, I found that unsubscribing a user also made it impossible for a user to resubscribe via the API. Changes to my single hidden field did apply to existing unsubscribed users. They just remain unsubscribed.
See:
https://stackoverflow.com/questions/36494975/can-not-re-subscribe-deleted-member
https://stackoverflow.com/questions/42159327/resubscribe-a-user-to-a-mailchimp-list-after-unsubscribe
Is there a way to check if the api key and list id is populated to show the newsletter form?
{% if mailchimpSubscribe is defined %}
{% include '_components/newsletter' %}
{% endif %}
Hi,
I am pretty sure this is a setup issue, but when i submit a contact form I am getting 404 errors.
for is as follows:
<form action="" id="search_form" class="newsletter-form" method="POST">
<input type="hidden" name="action" value="mailchimpsubscribe/list/Subscribe">
<input type="hidden" name="redirect" value="newsletter/thanks">
<input type="text" class="form-control" placeholder="Subscribe To Our Newsletter">
</form> <!-- end search form -->
and fromt he network panel in dev tools i can see the its sendign a request '/' which is returning a 404.
Version 2.0.4 is not synced on Packagist, and thus not installable by composer.
How would one go about ajaxifying mailchimp-subscribe-craft using vanilla JS? For some reason I can't get it to work properly (400 Bad Request), even though I'm submitting with POST and json header the exact same string as when using JQuery ajax... Javascript keeps kicking my ass.
HiAelvan,
It looks like your pluginisn't compatible with PHP 7.0
. We're running a Craft CMS 2.7.5
and getting a Parameter must be an array or an object that implements Countable
error in the Response:
<h1>PHP Error [500]</h1>
<p>count(): Parameter must be an array or an object that implements Countable (APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:67)</p>
<pre>#0 APP-PROJECT-FOLDER/core/app/etc/errors/ErrorHandler.php(184): Craft\ErrorHandler->handleError()
#1 APP-PROJECT-FOLDER/core/app/framework/base/CErrorHandler.php(133): Craft\ErrorHandler->handleError()
#2 APP-PROJECT-FOLDER/core/app/framework/base/CApplication.php(834): Craft\ErrorHandler->handle()
#3 APP-PROJECT-FOLDER/core/app/etc/web/WebApp.php(694): Craft\WebApp->handleError()
#4 unknown(0): Craft\WebApp->handleError()
#5 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(67): count()
#6 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(107): GuzzleHttp\Handler\CurlFactory->release()
#7 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): finish()
#8 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke()
#9 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(51): GuzzleHttp\Handler\{closure}()
#10 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(42): GuzzleHttp\Handler\{closure}()
#11 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Middleware.php(30): GuzzleHttp\PrepareBodyMiddleware->__invoke()
#12 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(68): GuzzleHttp\{closure}()
#13 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Middleware.php(59): GuzzleHttp\RedirectMiddleware->__invoke()
#14 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/HandlerStack.php(67): GuzzleHttp\{closure}()
#15 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Client.php(268): GuzzleHttp\HandlerStack->__invoke()
#16 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Client.php(123): GuzzleHttp\Client->transfer()
#17 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Client.php(129): GuzzleHttp\Client->requestAsync()
#18 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/guzzlehttp/guzzle/src/Client.php(87): GuzzleHttp\Client->request()
#19 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/pacely/mailchimp-apiv3/src/Mailchimp.php(150): GuzzleHttp\Client->__call()
#20 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/vendor/pacely/mailchimp-apiv3/src/Mailchimp.php(79): Mailchimp\Mailchimp->makeRequest()
#21 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/services/MailchimpSubscribeService.php(192): Mailchimp\Mailchimp->request()
#22 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/services/MailchimpSubscribeService.php(58): Craft\MailchimpSubscribeService->_getMemberByEmail()
#23 APP-PROJECT-FOLDER/plugins/mailchimpsubscribe/controllers/MailchimpSubscribe_ListController.php(34): Craft\MailchimpSubscribeService->subscribe()
#24 APP-PROJECT-FOLDER/core/app/framework/web/actions/CInlineAction.php(49): Craft\MailchimpSubscribe_ListController->actionSubscribe()
#25 APP-PROJECT-FOLDER/core/app/framework/web/CController.php(308): CInlineAction->runWithParams()
#26 APP-PROJECT-FOLDER/core/app/framework/web/CController.php(286): Craft\MailchimpSubscribe_ListController->runAction()
#27 APP-PROJECT-FOLDER/core/app/framework/web/CController.php(265): Craft\MailchimpSubscribe_ListController->runActionWithFilters()
#28 APP-PROJECT-FOLDER/core/app/framework/web/CWebApplication.php(282): Craft\MailchimpSubscribe_ListController->run()
#29 APP-PROJECT-FOLDER/core/app/etc/web/WebApp.php(837): Craft\WebApp->runController()
#30 APP-PROJECT-FOLDER/core/app/etc/web/WebApp.php(288): Craft\WebApp->_processActionRequest()
#31 APP-PROJECT-FOLDER/core/app/framework/base/CApplication.php(185): Craft\WebApp->processRequest()
#32 APP-PROJECT-FOLDER/core/app/index.php(73): Craft\WebApp->run()
#33 APP-PROJECT-FOLDER/www/index.php(23): require_once()
#34 /Users/mark/.composer/vendor/laravel/valet/server.php(158): require()
</pre>
Update: Upgrading to php 7.2 still doesn't correct the issue
This error sounds like a common issue for CraftCMS 2 plugins. Is this something you can update?
Thanks for your help and all you do for the community is awesome!
This line needs to be:
$listIdStr = $formListId !== '' ? $formListId : $settings->listId;
...as per the subscribe service. Otherwise the listId from settings is not used...
(also I note the docs on this are using the old action name still - input type="hidden" name="action" value="mailchimpSubscribe/list/CheckIfSubscribed
Seems too trivial to PR it but let me know if you want me to!
From the API documentation:
"Prior versions will no longer be supported after 2016, so all API users should begin transitioning to v3.0."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.