Skip to content

Instantly share code, notes, and snippets.

@sproutventure
Created November 16, 2010 18:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sproutventure/702177 to your computer and use it in GitHub Desktop.
Save sproutventure/702177 to your computer and use it in GitHub Desktop.
remove original action and create a new one.
function group_buying_subscription_new()
{
if( isset( $_POST['set-group-buying-subscription'] ) && !isset( $_POST['email_address'] ) ) {
setcookie( 'your-selected-location', $_POST['deal_location'], time( ) + 24 * 60 * 60 * 30, '/' );
wp_redirect( site_url() );
exit();
}
elseif( isset( $_POST['set-group-buying-subscription'] ) ) {
require_once 'utilities/MCAPI.class.php';
$apikey = get_buyer_config_option('group-buying-theme-mc-api-key');
$fieldname = get_buyer_config_option('group-buying-theme-mc-location-field');
$api = new MCAPI($apikey);
$api->setTimeout(5);
$merge_vars = array( $fieldname => $_POST['deal_location'] );
$listId = get_buyer_config_option('group-buying-theme-mc-list-id');
$retval = $api->listSubscribe( $listId, $_POST['email_address'], $merge_vars );
if ($api->errorMessage) {
Group_Buying_Utility::storeMessage($api->errorMessage);
}
if ( !$api->errorCode && $_POST['deal_location'] != null || $api->errorCode == '214' && $_POST['deal_location'] != null ) {
setcookie( 'your-selected-location', $_POST['deal_location'], time() + 24 * 60 * 60 * 30, '/' );
wp_redirect( site_url() );
exit();
}
}
}
remove_action( 'init', 'group_buying_subscription' );
add_action( 'init', 'group_buying_subscription_new' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment