Forked from strangerstudios/my_pmpro_levels_array.php
Created
February 19, 2014 10:52
-
-
Save cyberwani/9089749 to your computer and use it in GitHub Desktop.
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
<?php | |
/* | |
Reorder Levels on Levels Page | |
Adjust this code to your needs (change $levels_order) and | |
add this to your active theme's functions.php or a custom WordPress plugins. | |
*/ | |
function my_pmpro_levels_array($levels) | |
{ | |
//here is where you define the order of levels based on level id | |
$levels_order = array(1,3,2,4); | |
//loop through $levels_order array and pull levels from $levels | |
$new_levels = array(); | |
foreach($levels_order as $level_id) | |
{ | |
foreach($levels as $key => $level) | |
{ | |
if($level->id == $level_id) | |
{ | |
unset($levels[$key]); | |
$new_levels[] = $level; | |
break; | |
} | |
} | |
} | |
//include this line if you want to add any levels not specified in $levels_order to the end of the $new_levels array | |
$new_levels = array_merge($new_levels, $levels); | |
//returning our altered array | |
return $new_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