bb_gs_create_searchstring

Generate search string on profile update.

Description

bb_gs_create_searchstring( (type) $user_id, (type) $posted_field_ids, (type) $errors, (type) $old_values, (type) $new_values ); 

Parameters (5)

0. $user_id (type)
The user id.
1. $posted_field_ids (type)
The posted field ids.
2. $errors (type)
The errors.
3. $old_values (type)
The old values.
4. $new_values (type)
The new values.

Usage

  1. if ( !function_exists( 'bb_gs_create_searchstring' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-global-search/includes/functions.php'; 
  3.  
  4. // The user id. 
  5. $user_id = null; 
  6.  
  7. // The posted field ids. 
  8. $posted_field_ids = null; 
  9.  
  10. // The errors. 
  11. $errors = null; 
  12.  
  13. // The old values. 
  14. $old_values = null; 
  15.  
  16. // The new values. 
  17. $new_values = null; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = bb_gs_create_searchstring($user_id, $posted_field_ids, $errors, $old_values, $new_values); 
  21.  

Defined (1)

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

/includes/functions.php  
  1. function bb_gs_create_searchstring( $user_id, $posted_field_ids, $errors, $old_values, $new_values ) { 
  2.  
  3. if( !function_exists( 'bp_is_active' ) || !bp_is_active( 'xprofile' ) ) { 
  4. return; 
  5.  
  6. $items_to_search = buddyboss_global_search()->option('items-to-search'); 
  7.  
  8. $search_string = ''; 
  9.  
  10. foreach ( $new_values as $key => $value ) { 
  11.  
  12. if (in_array('xprofile_field_'.$key, $items_to_search) ) { 
  13. $search_string = $search_string .' '. $value['value']; 
  14.  
  15. update_user_meta($user_id, 'bbgs_search_string', $search_string); 
  16.