Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_custom_level_expiration_text.php
Created May 30, 2020 15:53
Swap the word Membership with Access in the PMPro expiration text.
<?php
/**
* Swap the word Membership with Access in the PMPro expiration text.
* Add this through a code snippet or custom plugin.
*/
function my_custom_level_expiration_text( $expiration_text, $level ) {
$expiration_text = str_replace( 'Membership', 'Access', $expiration_text );
return $expiration_text;
}
@ideadude
ideadude / pmpro_allow_weak_passwords.php
Created May 12, 2020 21:18
Tell PMPro allow weak passwords on the change password and reset password forms.
/**
* Tell PMPro allow weak passwords on the change password and reset password forms.
* Requires PMPro v2.3.3+
*/
add_filter( 'pmpro_allow_weak_passwords', '__return_true' );
@ideadude
ideadude / my_pmpro_forward_ipn.php
Last active August 7, 2020 16:01
Forward PMPro IPN messages from one site to another.
/**
* Forward PMPro IPNs to another PMPro site.
*/
function my_pmpro_forward_ipn() {
$fp = wp_remote_post( 'https://theothersite.com/wp-admin/admin-ajax.php?action=ipnhandler', $_POST );
}
add_action('wp_ajax_nopriv_ipnhandler', 'my_pmpro_forward_ipn', 5);
add_action('wp_ajax_ipnhandler', 'my_pmpro_forward_ipn', 5);
@ideadude
ideadude / my_pmpro_admin_orders_filters_past30.php
Created April 29, 2020 15:12
Add a filter to the PMPro orders table to show the 30 days of orders.
<?php
/**
* Add a filter to the PMPro orders table
* in the WordPress dashboard
* to show the past 30 days of orders.
* Requires PMPro 2.3 or higher.
* Add this code through a Code Snippet or Custom Plugin.
*/
// Add the filter.
function my_pmpro_admin_orders_filters_past30( $filters ) {
@ideadude
ideadude / pmpro_international_addresses.php
Created April 7, 2020 03:50
Force international addresses in PMPro.
<?php
// Force international addresses (include country, longer state field).
add_filter( 'pmpro_international_addresses', '__return_true' );
?>
@ideadude
ideadude / my_pmpro_bp_lockdown_all_bp.php
Created April 1, 2020 16:28
Allow non-members to view the BuddyPress profile pages even if you are "locking down all of BuddyPress".
/**
* This gist will disable the default behavior in PMPro BuddyPress 5.2.5 or earlier,
* which would redirect users away from the BP profile pages if you had
* "all of BuddyPress" locked down for non-members or members of a specific level.
*
* We might address this in future versions of the Add-On, but for now, you can use
* this gist. Add it to a Code Snippet or a custom plugin.
*/
// First disable the default PMPro BuddyPress behavior.
@ideadude
ideadude / my_pmpro_checkout_level_discounts.php
Created March 17, 2020 19:56
Discounts when purchasing multiple levels with PMPro MMPU
/**
* Discounts when purchasing multiple levels with PMPro MMPU
*
* 1. Add this to a custom plugin or code snippet.
* 2. Adjust the discount_levels array.
* 3. Adjust the logic for when the price is changed and how much.
* 4. Make sure to remove the billing_amount lines if you don't have recurring billing.
*/
function my_pmpro_checkout_level_discounts( $level ) {
$discount_levels = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
@ideadude
ideadude / my_sync_stripe_events.php
Created March 13, 2020 17:43
Synchronize Stripe invoice.payment_succeeded Events in PMPro.
/**
* Synchronize Stripe invoice.payment_succeeded Events
* Warning. This code will update your database,
* create new orders, and potentially email your customers.
* Proceed with caution. Back up your database.
* You will likely want to pair this script with a plugin
* or script to disable all email.
* The default limit is 200 events. You may need to increase this
* or update the script to paginate and run events in batches.
* The default delay between event calls is 2 seconds.
@ideadude
ideadude / pmpro-customizations.php
Last active March 11, 2020 18:47 — forked from strangerstudios/pmpro-customizations.php
Tax solution for British Columbia, Canada to be used with Paid Memberships Pro
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for PMPro
Version: .2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@ideadude
ideadude / my_hide_jnews_ads_from_members.php
Created March 5, 2020 21:26
Unhook JNews Theme Ads if the user is a PMPro member
// Unhook JNews Theme Ads if the user is a PMPro member
// Add this code into a custom plugin.
// I am not sure that this is running late enough to override
// the JNews Ad insert. You may need to hook into init later
// or even another hook that runs later.
function my_hide_jnews_ads_from_members() {
// do nothing if PMPro is not running
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return;
}