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
/* | |
When users cancel (are changed to membership level 0) we give them another "cancelled" level. | |
Can be used to downgrade someone to a free level when they cancel. | |
Will allow members to the "cancel level" to cancel from that though. | |
*/ | |
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id) | |
{ | |
//set this to the id of the level you want to give members when they cancel | |
$cancel_level_id = 1; |
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 | |
/* | |
Filter pmpro_has_membership_access based on paid membership access. | |
*/ | |
function my_pmpro_has_membership_access_filter( $hasaccess, $mypost, $myuser, $post_membership_levels ) { | |
$my_paid_level_ids = array(5,6,7); | |
// Check if the user doesn't have access | |
if( ! $hasaccess ) { | |
// If this post has membership levels associated with it and is supposed to be locked by the Addon Plugin |
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 | |
/** | |
* Assign a membership level based on product ID variation purchase. | |
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function add_membership_for_variation_pricing( $order_id ) { | |
global $wpdb, $pmprowoo_product_levels; | |
// quitely exit if PMPro isn't active |
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
/* | |
Change cancellation to set expiration date for next payment instead of cancelling immediately. | |
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly). | |
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs. | |
*/ | |
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.) | |
function my_pmpro_before_change_membership_level($level_id, $user_id) { | |
//are we on the cancel page? |
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
/* | |
When users cancel (are changed to membership level 0) we give them another "cancelled" level. Can be used to downgrade someone to a free level when they cancel. | |
*/ | |
function pmpro_after_change_membership_level_default_level($level_id, $user_id) | |
{ | |
//if we see this global set, then another gist is planning to give the user their level back | |
global $pmpro_next_payment_timestamp; | |
if(!empty($pmpro_next_payment_timestamp)) | |
return; | |
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
/* | |
Only let level 1 members sign up if they use a discount code. | |
Place this code in your active theme's functions.php or a custom plugin. | |
*/ | |
function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration) | |
{ | |
//only bother if things are okay so far | |
if(!$pmpro_continue_registration) | |
return $pmpro_continue_registration; |
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
/* | |
Redirect away from the checkout page if you don't have a required level. | |
*/ | |
function my_template_redirect_upgrade() | |
{ | |
global $pmpro_pages, $pmpro_level; | |
if(empty($pmpro_pages)) | |
return; | |
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 | |
//Save the pmpro_show_level_ID field | |
function pmpro_hide_level_from_levels_page_save( $level_id ) { | |
if( $level_id <= 0 ) { | |
return; | |
} | |
$limit = $_REQUEST['pmpro_show_level']; | |
update_option( 'pmpro_show_level_'.$level_id, $limit ); | |
} | |
add_action( 'pmpro_save_membership_level','pmpro_hide_level_from_levels_page_save' ); |
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: PMPro Hidden Levels | |
Plugin URI: http://www.paidmembershipspro.com/pmpro-hidden-levels/ | |
Description: With this plugin, select levels are removed from the levels page but still available for checkout if you visit the checkout URL directly. | |
Version: .1 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ |
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 | |
/** | |
* Copy the function below into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* This function uses the gettext filter which will change all text occurences of Billing Address to Address in Paid Memberships Pro. | |
*/ | |
function change_text_billing_pmpro( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Billing Address' : | |
$translated_text = __( 'Address', 'paid-memberships-pro' ); | |
break; |