Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JarrydLong/5e9b477ad667cad45a6a7d75960af844 to your computer and use it in GitHub Desktop.

Select an option

Save JarrydLong/5e9b477ad667cad45a6a7d75960af844 to your computer and use it in GitHub Desktop.
Make certain WooCommerce products not-purchasable for non-members
<?php
/**
* Stop non-members from purchasing products if they do not have an active Paid Memberships Pro Level.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function stop_pmpro_members_from_buying_woo( $is_purchasable, $product ) {
// Check if the user has an active membership level.
if( pmpro_hasMembershipLevel() ) {
return false;
}
return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'stop_pmpro_members_from_buying_woo', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment