bp_core_get_directory_page_ids

Fetch a list of BP directory pages from the appropriate meta table.

Description

(array|string) bp_core_get_directory_page_ids( (string) $status = 'active' ); 

Returns (array|string)

An array of page IDs, keyed by component names, or an empty string if the list is not found.

Parameters (1)

0. $status — Optional. (string) => 'active'
Active. to return only pages associated with active components, all to return all saved pages. When running save routines, use all to avoid removing data related to inactive components. Default: active..

Usage

  1. if ( !function_exists( 'bp_core_get_directory_page_ids' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3. $status = 'active'; 
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_core_get_directory_page_ids($status); 
  7.  

Defined (1)

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

/bp-core/bp-core-functions.php  
  1. function bp_core_get_directory_page_ids( $status = 'active' ) { 
  2. $page_ids = bp_get_option( 'bp-pages' ); 
  3.  
  4. // Ensure that empty indexes are unset. Should only matter in edge cases. 
  5. if ( !empty( $page_ids ) && is_array( $page_ids ) ) { 
  6. foreach( (array) $page_ids as $component_name => $page_id ) { 
  7. if ( empty( $component_name ) || empty( $page_id ) ) { 
  8. unset( $page_ids[ $component_name ] ); 
  9.  
  10. // 'register' and 'activate' do not have components, but should be whitelisted. 
  11. if ( 'register' === $component_name || 'activate' === $component_name ) { 
  12. continue; 
  13.  
  14. // Trashed pages should not appear in results. 
  15. if ( 'trash' == get_post_status( $page_id ) ) { 
  16. unset( $page_ids[ $component_name ] ); 
  17.  
  18.  
  19. // Remove inactive component pages, if required. 
  20. if ( 'active' === $status && ! bp_is_active( $component_name ) ) { 
  21. unset( $page_ids[ $component_name ] ); 
  22.  
  23. /** 
  24. * Filters the list of BP directory pages from the appropriate meta table. 
  25. * @since 1.5.0 
  26. * @param array $page_ids Array of directory pages. 
  27. */