bp_get_member_types

Get a list of all registered member type objects.

Description

(array) bp_get_member_types( (array) $args = array(), (string) $output = 'names', (string) $operator = 'and' ); 

Returns (array)

A list of member type names or objects.

Parameters (3)

0. $args — Optional. (array) => array()
An array of key => value arguments to match against the member type objects. Default empty array.
1. $output — Optional. (string) => 'names'
The type of output to return. Accepts names or objects.. Default names.
2. $operator — Optional. (string) => 'and'
The logical operation to perform. or means only one element from the array needs to match; and. means all elements must match. Accepts or or and.. Default and..

Usage

  1. if ( !function_exists( 'bp_get_member_types' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // Optional. An array of key => value arguments to match against 
  5. // the member type objects. Default empty array. 
  6. $args = array(); 
  7.  
  8. // Optional. The type of output to return. Accepts 'names' 
  9. // or 'objects'. Default 'names'. 
  10. $output = 'names'; 
  11. $operator = 'and'; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_get_member_types($args, $output, $operator); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_get_member_types( $args = array(), $output = 'names', $operator = 'and' ) { 
  2. $types =buddypress)->members->types; 
  3.  
  4. $types = wp_filter_object_list( $types, $args, $operator ); 
  5.  
  6. /** 
  7. * Filters the array of member type objects. 
  8. * This filter is run before the $output filter has been applied, so that 
  9. * filtering functions have access to the entire member type objects. 
  10. * @since 2.2.0 
  11. * @param array $types Member type objects, keyed by name. 
  12. * @param array $args Array of key=>value arguments for filtering. 
  13. * @param string $operator 'or' to match any of $args, 'and' to require all. 
  14. */ 
  15. $types = apply_filters( 'bp_get_member_types', $types, $args, $operator ); 
  16.  
  17. if ( 'names' === $output ) { 
  18. $types = wp_list_pluck( $types, 'name' ); 
  19.  
  20. return $types;