This file contains hidden or 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 | |
/** | |
* Change the default PMPro WooCommerce bahavior | |
* and make membership products not purchasable | |
* if a user already has any other membership level. | |
*/ | |
// First disable the core PMPro WC callaback and set up our own. | |
function my_pmprowoo_init() { | |
remove_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 ); | |
add_filter( 'woocommerce_is_purchasable', 'my_pmprowoo_is_purchasable', 5, 2 ); |
This file contains hidden or 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; | |