paid-memberships-pro
paid-memberships-pro copied to clipboard
Idea: pmpro_getAllLevels should include "all" get_pmpro_membership_level_meta
When pmpro_getAllLevels() is called https://github.com/strangerstudios/paid-memberships-pro/blob/2d0acf70f615d3e72a4e1154ddc2492cac609785/includes/functions.php#L2262
it should include all custom meta that has been added to any level via get_pmpro_membership_level_meta()
Consider how this solution works for grabbing ALL user meta:
$allmeta = array_map( function( $a ){ return $a[0]; }, get_user_meta( $user_id ) );
For example
// running this
update_pmpro_membership_level_meta( 1, "custom_meta_key", "my value");
// does not cause this to happen when pmpro_getAllLevels() is called
stdClass Object(
[id] => 1
[name] => Cool Membership
...ect...
[custom_meta_key] => my value
)
which means this does not work
$pmpro_all_levels = pmpro_getAllLevels(false, true);
foreach($pmpro_all_levels as $level) {
echo $level->custom_meta_key; // convenient, but not work
}
which means this has to be done
$pmpro_all_levels = pmpro_getAllLevels(false, true);
foreach($pmpro_all_levels as $level) {
// we must instead run this
$meta = get_pmpro_membership_level_meta($level->id, "custom_meta_key", true); // notconvenient
}