Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@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;
}
@ideadude
ideadude / htaccess.txt
Created March 4, 2020 12:24
Lock down ONLY PDFs with Paid Memberships Pro
RewriteBase /
RewriteRule ^wp-content/uploads/(.*\.pdf)$ /wp-content/plugins/paid-memberships-pro/services/getfile.php [L]
@ideadude
ideadude / getfile.php
Created March 4, 2020 12:21
Enable Paid Memberships Pro's getfile script to lock down files.
define('PMPRO_GETFILE_ENABLED', true);
@ideadude
ideadude / htaccess.txt
Created March 4, 2020 12:20
Locking down files with PMPro.
RewriteBase /
RewriteRule ^wp-content/uploads/(.*)$ /wp-content/plugins/paid-memberships-pro/services/getfile.php [L]
@ideadude
ideadude / htaccess.txt
Last active February 8, 2022 20:36
Locking down only PDF,DOC,DOCX,PPT,ZIP files with Paid Memberships Pro
RewriteBase /
RewriteRule ^wp-content/uploads/.*(\.pdf|\.doc|\.docx|\.ppt|\.zip)$ /wp-content/plugins/paid-memberships-pro/services/getfile.php [L]