Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Forked from kerijacoby/hide-level
Last active December 5, 2023 20:32
Show Gist options
  • Save kimwhite/cd4aa8b08560d5dfaec728a5a1035c02 to your computer and use it in GitHub Desktop.
Save kimwhite/cd4aa8b08560d5dfaec728a5a1035c02 to your computer and use it in GitHub Desktop.
Hide a level from non-members
<?php // do not copy this line.
/**
* This recipe will hide level 2 from non-members
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function adjusting_the_pmpro_levels_array( $levels ) {
if( !pmpro_hasMembershipLevel() ) {
unset( $levels[2] ); // hide level 14 from non-members
}
return $levels;
}
add_filter( 'pmpro_levels_array', 'adjusting_the_pmpro_levels_array' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment