View Single Post
  #1  
Old 05-13-2011, 08:01 AM
jGas jGas is offline
 
Join Date: May 2007
Posts: 172
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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-->";
}
Many thanks for your time
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01178 seconds
  • Memory Usage 1,773KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete