Created
January 25, 2016 22:17
-
-
Save joeynovak/c8138aabdcb37384630f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Novak Solutions Memberium De-Dupe Contact | |
Plugin URI: | |
Description: This plugin will automatically de-dupe contacts from orders when redirect to a thankyou page. | |
Author: Joey Novak | |
Version: 0.1a | |
Author URI: http://joeynovak.com | |
*/ | |
function novaksolutions_dedupe_shortcode() { | |
global $i2sdk; | |
$orderInfo = $i2sdk->isdk->dsLoad('Job', $_GET['orderId'], array('ContactId', 'DateCreated')); | |
//Order has to have been placed in the last 24 hours (this is a sloppy way to account for time zone differences...). | |
if($orderInfo['ContactId'] != memb_getContactId() && time() - strtotime($orderInfo['DateCreated']) < 12 * 60 * 60){ | |
$i2sdk->isdk->mergeCon(memb_getContactId(), $orderInfo['ContactId']); | |
echo '<span style="display: none;">' . 'Merged Memberium Contact: ' . memb_getContactId() . ' with order contact: ' . $orderInfo['ContactId'] . '</span>'; | |
} | |
} | |
add_shortcode( 'novaksolutions-dedupe', 'novaksolutions_dedupe_shortcode' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment