• Hi,
    I wonder, how could I display only particular membership levels on a page, not all of them.
    I am new to PHP,so if anyone could help me get only needed membership levels from array, by ID or name, I would be really thankful.
    That the default page which displays all levels, how could I modify it ?

    <?php
    global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user;

    $pmpro_levels = pmpro_getAllLevels(false, true);
    $pmpro_level_order = pmpro_getOption(‘level_order’);

    if(!empty($pmpro_level_order))
    {
    $order = explode(‘,’,$pmpro_level_order);

    //reorder array
    $reordered_levels = array();
    foreach($order as $level_id) {
    foreach($pmpro_levels as $key=>$level) {
    if($level_id == $level->id)
    $reordered_levels[] = $pmpro_levels[$key];
    }
    }

    $pmpro_levels = $reordered_levels;
    }

    $pmpro_levels = apply_filters(“pmpro_levels_array”, $pmpro_levels);

    if($pmpro_msg)
    {
    ?>
    <div class=”pmpro_message <?php echo $pmpro_msgt?>”><?php echo $pmpro_msg?></div>
    <?php
    }
    ?>
    <table id=”pmpro_levels_table” class=”pmpro_checkout”>
    <thead>
    <tr>
    <th><?php _e(‘Level’, ‘pmpro’);?></th>
    <th><?php _e(‘Price’, ‘pmpro’);?></th>
    <th> </th>
    </tr>
    </thead>
    <tbody>
    <?php
    $count = 0;
    foreach($pmpro_levels as $level)
    {
    if(isset($current_user->membership_level->ID))
    $current_level = ($current_user->membership_level->ID == $level->id);
    else
    $current_level = false;
    ?>
    <tr class=”<?php if($count++ % 2 == 0) { ?>odd<?php } ?><?php if($current_level == $level) { ?> active<?php } ?>”>
    <td><?php echo $current_level ? “{$level->name}” : $level->name?></td>
    <td>
    <?php
    if(pmpro_isLevelFree($level))
    $cost_text = “” . _e(“Free”, “pmpro”) . ““;
    else
    $cost_text = pmpro_getLevelCost($level, true, true);
    $expiration_text = pmpro_getLevelExpiration($level);
    if(!empty($cost_text) && !empty($expiration_text))
    echo $cost_text . “
    ” . $expiration_text;
    elseif(!empty($cost_text))
    echo $cost_text;
    elseif(!empty($expiration_text))
    echo $expiration_text;
    ?>
    </td>
    <td>
    <?php if(empty($current_user->membership_level->ID)) { ?>
    id, “https”)?>”><?php _e(‘Select’, ‘pmpro’);?>
    <?php } elseif ( !$current_level ) { ?>
    id, “https”)?>”><?php _e(‘Select’, ‘pmpro’);?>
    <?php } elseif($current_level) { ?>

    https://www.ads-software.com/plugins/paid-memberships-pro/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Display only chosen membership levels on a page’ is closed to new replies.