public

remove original action and create a new one.

  • Download Gist
Override GBS subscription
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
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' );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.