bboss_global_search_remove_search_types_for_guests

Remove 'messages' and 'notifications' from search, if user is not logged In.

Description

bboss_global_search_remove_search_types_for_guests( (mixed) $search_types ); 

Parameters (1)

0. $search_types (mixed)
The search types.

Usage

  1. if ( !function_exists( 'bboss_global_search_remove_search_types_for_guests' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-global-search/includes/filters.php'; 
  3.  
  4. // The search types. 
  5. $search_types = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bboss_global_search_remove_search_types_for_guests($search_types); 
  9.  

Defined (1)

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

/includes/filters.php  
  1. function bboss_global_search_remove_search_types_for_guests( $search_types ) { 
  2. if( !is_admin() && !empty( $search_types ) && !is_user_logged_in() ) { 
  3. $items_to_remove = array( 'messages', 'notifications' ); 
  4. $filtered_search_types = array(); 
  5. foreach( $search_types as $search_type ) { 
  6. if( !in_array( $search_type, $items_to_remove ) ) { 
  7. $filtered_search_types[] = $search_type; 
  8.  
  9. $search_types = $filtered_search_types; 
  10. return $search_types;