Forked from strangerstudios/my_pmpro_levels_array.php
Last active
March 13, 2018 19:49
-
-
Save pbrocks/ca59389d03c83a8bdebdd4c7f7fa2080 to your computer and use it in GitHub Desktop.
Use pmpro_levels_array filter to remove specific levels from your levels array. In this case, we are removing Free levels, leaving only paid levels to be returned to your PMPro levels array.
This file contains 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
/** | |
* The function my_pmpro_levels_array is an arbitrarily named function, which | |
* you can rename to something more meaningful, as long as it is uniquely | |
* named on this site. | |
* | |
* @param array $levels Input the array of levels from your site | |
* @return array Output all paid levels, ie NOT the free level(s) | |
*/ | |
function my_pmpro_levels_array( $levels ) { | |
$newlevels = array(); | |
foreach ( $levels as $level ) { | |
if ( ! pmpro_isLevelFree( $level ) ) { | |
$newlevels[] = $level; | |
} | |
} | |
return $newlevels; | |
} | |
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