1. Home
  2. Knowledge Base
  3. API
  4. Function Reference
  5. 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.


This function accepts no parameters.


Returns a string containing the filtered list.

Example Code

     //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


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

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support