Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / PMPRO_LICENSE_NAG.php
Created June 18, 2020 16:51
Disable the PMPro license nag.
<?php
// Add this to your wp-config.php file.
define('PMPRO_LICENSE_NAG', false);
@ideadude
ideadude / pmpro_required_fields.css
Created June 11, 2020 13:22
CSS to show the word "Required" next to the asterisks on the checkout form.
span.pmpro_asterisk:after { content: "Required" }
@ideadude
ideadude / my_lockdown_files_by_media_category.php
Created June 3, 2020 20:51
Restrict files in the media library based on media category when using Paid Memberships Pro and Media Library Categories
<?php
/**
* Restrict files in the media library based on media category.
* Required plugins:
* - Paid Memberships Pro
* - Media Library Categories
* Must have PMPro set up to run files through the getfile.php script.
* See this post: https://www.paidmembershipspro.com/locking-down-protecting-files-with-pmpro/
* Add a 'members' category or adjust the code below to use your categories.
*/
@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 );