Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaximilianoRicoTabo/5bf508c8a099f5571b8b484d7ffbd076 to your computer and use it in GitHub Desktop.
Save MaximilianoRicoTabo/5bf508c8a099f5571b8b484d7ffbd076 to your computer and use it in GitHub Desktop.
Exclude certain levels from checkout page
<?php
function pmpro_custom_filter_checkout_levels( $pmpro_level ) {
// get the current user
$user = wp_get_current_user();
// if the user is logged in
if ( $user->ID ) {
// get the user's membership level
$level = pmpro_getMembershipLevelForUser( $user->ID );
// if the user has a membership level 1
if ( $level->id == 1 ) {
// remove the level from the array
unset( $pmpro_level[3] );
}
}
return $pmpro_level;
}
add_filter( 'pmpro_levels_array', 'pmpro_custom_filter_checkout_levels' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment