Skip to content

Instantly share code, notes, and snippets.

@cartpauj
cartpauj / mepr-custom-mailchimp-data.php
Created April 1, 2016 16:04
Custom code which can be used to send custom meta data to MailChimp
<?php //This code can be placed in a plugin like My Custom Functions (just omit this top line when copying)
function add_additional_mailchimp_usermeta($args, $contact, $list_id) {
$date = get_user_meta($contact->ID, 'mepr_some_date_field', true); //mepr_some_date_field SHOULD BE REPLACED WITH YOUR date field's slug
$args['merge_vars']['MMERGE_77'] = $date; //MMERGE_77 SHOULD BE REPLACED WITH YOUR SPECIFIC MERGE FIELD NAME
return $args;
}
add_filter('mepr-mailchimp-add-subscriber-args', 'add_additional_mailchimp_usermeta', 11, 3);
@cartpauj
cartpauj / pretty-link-pro-permalinks.php
Created June 10, 2016 17:56
Pretty Link Pro - Replace WordPress' Permalinks with pretty links when possible
@cartpauj
cartpauj / mepr-autoembed-thankyou-page-messages.php
Created June 7, 2016 16:09
WP Autoembed MemberPress thank you page messages
<?php
/* Enter Your Custom Functions Here */
function mepr_autoembed_thankyou_message($message) {
global $wp_embed;
if(!class_exists('MeprTransaction')) { return $message; }
if(!isset($_REQUEST['trans_num'])) { return $message; }
$txn = new MeprTransaction();
@cartpauj
cartpauj / affiliate-royale-memberpress-tracking-on-separate-domains.php
Created August 9, 2017 18:35
How to track commissions from MemberPress when Affiliate Royale is on a separate domain then MemberPress.
<?php // Set up a custom page template in your theme, and choose that template for your MemberPress thank-you page. The following should be in that template.
if(isset($_GET['trans_num']) && ($txn = MeprTransaction::get_one_by_trans_num($_GET['trans_num']))):
?>
<img src="http://AFFILIATE-SITE.com/index.php?plugin=wafp&controller=transactions&action=track&amount=<?php echo $txn->amount; ?>&order_id=<?php echo $txn->id; ?>&prod_id=<?php echo $txn->product_id; ?>" width="1px" height="1px" style="display: none;" />
<?php endif; ?>
@cartpauj
cartpauj / pretty-link-stats-by-group.sql
Created August 9, 2017 21:45
Pretty Link stats by Groups - QUERY
@cartpauj
cartpauj / ajax-request-memberpress-developer-tools-rest-api-json.html
Created March 6, 2018 20:06
Sample jQuery JSON REST API - MemberPress Developer Tools - Basic Authentication
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Access</title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var settings = {
async: true,
@cartpauj
cartpauj / mepr-active-inactive.php
Created March 14, 2018 15:16
Do things when a user becomes active on a membership, and when they become inactive on a membership
<?php
function listen_to_mepr_events($event) {
$obj = $event->get_data();
//$obj might be a MeprTransaction object or a MeprSubscription object
if(!($obj instanceof MeprTransaction) && !($obj instanceof MeprSubscription)) {
return; // nothing here to do if we're not dealing with a txn or sub
}
$member = $obj->user();
@cartpauj
cartpauj / mepr-upme-activate.php
Last active March 15, 2018 00:59
MemberPress + UPME integration
<?php
/*
Plugin Name: MemberPress + UPME
Plugin URI: https://memberpress.com
Description: Activates UPME profiles when a user signs up via MemberPress.
Version: 1.0
Author: Caseproof, LLC
Author URI: http://caseproof.com/
Copyright: 2004-2014, Caseproof, LLC
*/
@cartpauj
cartpauj / memberpress-address-to-paypal-standard.php
Created July 19, 2018 16:07
Pass address to PayPal Standard in MemberPress
<?php
function mepr_add_address_to_paypal($args, $txn) {
$user_id = $txn->user_id;
$args['address1'] = get_user_meta($user_id, 'mepr-address-one', true);
$args['address2'] = get_user_meta($user_id, 'mepr-address-two', true);
$args['city'] = get_user_meta($user_id, 'mepr-address-city', true);
$args['country'] = get_user_meta($user_id, 'mepr-address-country', true);
$args['state'] = get_user_meta($user_id, 'mepr-address-state', true);
$args['zip'] = get_user_meta($user_id, 'mepr-address-zip', true);
return $args;
@cartpauj
cartpauj / memberpress-ban-hammer.php
Created April 23, 2018 17:06
MemberPress - Ban Hammer - Integration
<?php
function validate_mepr_signup_via_banhammer($errors) {
if( class_exists('MeprOptions') &&
class_exists('BanHammer') &&
is_email($_POST['user_email']) &&
((new BanHammer)->banhammer_drop($_POST['user_name'], $_POST['user_email'], (new WP_Error())))
) {
$errors[] = (new BanHammer)->options['message'];
}