Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Created March 2, 2016 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eighty20results/1ba3a95468d613423298 to your computer and use it in GitHub Desktop.
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
<?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