1. Home
  2. API
  3. Function Reference
  4. Function Reference: wlmapi_the_levels

Function Reference: wlmapi_the_levels

Retrieves a list of all membership levels passed through the filter: wlmapi_the_levels. If no filter is applied, this function will return the unfiltered array, i.e. the same output as wlmapi_get_levels.

Parameters

This function accepts no parameters.

Return

Returns a string containing the filtered list.

Example Code

<?php
     //On the page displaying the levels
     $levels = wlmapi_the_levels();
     echo $levels;

     //In theme functions file or plugin
     function filter_levels($levels) {
          //Navigate down to the levels array
          $levels_array = $levels['levels']['level'];

          //Start output
          $output = '<ul>';

         //Loop through levels to get level name
         foreach ( $levels_array as $level ) {
              $output .= '<li>' . $level['name'] . '</li>';
         }

         //End output
         $output .= '</li>';

         return $output;
}

     add_filter('wlmapi_the_levels', 'filter_levels');
?>

Example Output

  • Test Level 1
  • Test Level 2
  • Test Level 3

Notes

This functions returns WLMAPIMethods::the_levels() in core/api-helper/class-api-methods.php

Updated on August 14, 2020

Was this article helpful?

Related Articles

Not the solution you were looking for?
Click the link below to submit a support ticket
Submit Ticket