Created
February 12, 2018 09:04
-
-
Save andrewlimaza/bd06b6f47014e22011e87ce419558422 to your computer and use it in GitHub Desktop.
Stop users from purchasing a lower membership level Paid Memberships Pro WooCommerce
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 | |
/** | |
* This stops users from purchasing a lower level membership through WooCommerce. (Assume lower level ID is '1') | |
* If user has level 2 or 3, stop them from purchasing level 1 membership. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
// Stop users from purchasing a lower membership level via WooCommerce. | |
function pmpro_lower_level_is_purchasable( $is_purchasable, $product ) { | |
if( pmpro_hasMembershipLevel( array( '2', '3' ) ) ) { //change '2','3' to higher levels to stop users from signing up for a 'lower' level. | |
if( 80 == $product->id ) { //change product ID for lower level product ID. | |
$is_purchasable = false; | |
} | |
} | |
return $is_purchasable; | |
} | |
add_filter( 'woocommerce_is_purchasable', 'pmpro_lower_level_is_purchasable', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment