Created
November 1, 2024 20:21
-
-
Save MaximilianoRicoTabo/5bf508c8a099f5571b8b484d7ffbd076 to your computer and use it in GitHub Desktop.
Exclude certain levels from checkout page
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 | |
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