Created
March 2, 2016 00:13
-
-
Save eighty20results/1ba3a95468d613423298 to your computer and use it in GitHub Desktop.
Hide all levels except the current user's membership level from the list of membership levels on display
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 | |
| /* | |
| * Hide some levels from Levels page | |
| */ | |
| function my_pmpro_levels_array($levels) { | |
| global $current_user; | |
| // if the user is logged in | |
| if (!empty($current_user->ID)) | |
| { | |
| // remove all but the current user's level from the list of memberships | |
| foreach($levels as $key=>$level) | |
| if (isset($current_user->membership_level) && ($current_user->membership_level->id != $level->id)) | |
| unset($levels[$key]); | |
| } | |
| return $levels; | |
| } | |
| add_filter('pmpro_levels_array', 'my_pmpro_levels_array'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment