The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Mailchimp plugin for 3.8.7: What do I need to modify?
Hi, this code is working great on the site where I found it, http://www.bestrecipes.com.au/site/mailchimp.html, that is running 3.8.3 but not on my board that is 3.8.7.
This is the plugin code: Code:
require_once 'mailchimp/MCAPI.class.php'; // location of API file, relative to forum root directory $apikey= 'myapikey-us2'; // your API key $listId = '3af3706004321'; // the list ID // Connect to the MailChimp server $api = new MCAPI($apikey); if ($api->errorCode!=''){ // an error occurred while logging in, errors commented in HTML echo "<!-- code:".$api->errorCode."-->"; echo "<!-- msg :".$api->errorMessage."-->"; die(); } // get current user details $my_email=($vbulletin->userinfo['email']); // profile fields are best set up as single-selection radio buttons, // use multiple profile fields for interest groups and mail format // vBulletin profile field options: // use Yes/No options (use HTML/Text for mail format) // Set default: Yes // Field Required: No but display at registration // Field Editable by User: Only at registration // Handle unsubscribes and profile updating via links in mailings, or another API plugin $news1=($vbulletin->userinfo['field12']); // add custom profile field number for interest group 1 // $news2=($vbulletin->userinfo['field14']); // add custom profile field number for interest group 2 // $news3=($vbulletin->userinfo['field15']); // add custom profile field number for interest group 3 $newsformat=strtolower(($vbulletin->userinfo['field13'])); // profile field number for mail format, html or text // add interest group names, note trailing commas in all but last one - a quick hack but it works! if ($news1=='Yes') { $interests='Interest group name here,'; // escape apostrophes in name with a backslash i.e. What\'s On } if ($news2=='Yes') { $interests.='Interest group name here,'; } if ($news3=='Yes') { $interests.='Interest group name here'; } $merge_vars = array('INTERESTS'=>$interests); // only send request if subscribed to at least 1 newsletter if ($news1=='Yes' || $news2=='Yes' || $news3=='Yes') { $retval = $api->listSubscribe( $listId, $my_email, $merge_vars, $newsformat ); } if (!$retval){ // return error codes, commented in HTML echo "<!--Newsletter failed!-->"; echo "<!--\tCode=".$api->errorCode."-->"; echo "<!--\tMsg=".$api->errorMessage."-->"; // email backup for API failures, multiple subscribes etc. $to = 'info@musicadigitale.net'; $subject = 'Newsletter API failed'; $message = "The following member details were not subscribed by the API:\n"; $message .= "Email: $my_email\n"; $message .= "Interest groups: $interests\n"; $message .= "Mail format: $newsformat\n"; $message .= "Error message: " . $api->errorMessage . ""; $headers = "From: MailChimp API <adminemail@domain.com>\n"; $headers .= "Reply-To: adminemail@domain.com\n"; $headers .= "X-Mailer: Your forum name\n"; mail($to, $subject, $message, $headers); } else { echo "<!--Newsletter subscribed ok-->"; } |
#2
|
|||
|
|||
In the line:
Code:
$news1=($vbulletin->userinfo['field12']); Did you change the field to match your actual custom profile field number? Also if those are really your api key and list number I'm guessing you shouldn't be posting them (and if they aren't, did you enter your values there when you tried it?). You didn't say what actually happens on your site. |
#3
|
|||
|
|||
Thanks for your reply!
Don't worry, I removed the correct keys and list number before posting here Also the fields are correct. This plugin works during registration of a new user. When I try to register, the user is correctly registered but 1) it's not added to the mailing list 2) I get a white page instead of "you need to confirm your account, check your email" page... That's strange! |
#4
|
|||
|
|||
Sorry, but occasionally someone will copy a block of code and have no idea about how it shoud be edited
Anyway, I'm probably going to say a couple more obvious things, but: if you see a white page I'd guess that maybe it's hitting that die(). Did you "view source" of the blank page to see if those html comments are there? Also maybe make sure that the MCAPI.class.php file is in the right place, but I think you'd see an error message if is wasn't. |
#5
|
|||
|
|||
No problem
Well I can't view the source because it isn't a real blank page, it's a "Content Encoding Error" page (firefox reports this error) MCAPI.class.php file is in the right place |
#6
|
|||
|
|||
Hmm...maybe you could comment out the die and put the code after that block in an else and see what that does.
|
#7
|
|||
|
|||
If I comment the "die" I get the same message as before... maybe because it isn't an api error...?
|
#8
|
|||
|
|||
Yeah, looks like my guess was wrong.
|
#9
|
|||
|
|||
The problem is, that on a vbulletin 3.8.3 it IS working...
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|