bp_ajax_get_suggestions

AJAX endpoint for Suggestions API lookups.

Description

bp_ajax_get_suggestions(); 

Usage

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

Defined (1)

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

/bp-activity/bp-activity-actions.php  
  1. function bp_ajax_get_suggestions() { 
  2. if ( ! bp_is_user_active() || empty( $_GET['term'] ) || empty( $_GET['type'] ) ) { 
  3. wp_send_json_error( 'missing_parameter' ); 
  4. exit; 
  5.  
  6. $args = array( 
  7. 'term' => sanitize_text_field( $_GET['term'] ),  
  8. 'type' => sanitize_text_field( $_GET['type'] ),  
  9. ); 
  10.  
  11. // Support per-Group suggestions. 
  12. if ( ! empty( $_GET['group-id'] ) ) { 
  13. $args['group_id'] = absint( $_GET['group-id'] ); 
  14.  
  15. $results = bp_core_get_suggestions( $args ); 
  16.  
  17. if ( is_wp_error( $results ) ) { 
  18. wp_send_json_error( $results->get_error_message() ); 
  19. exit; 
  20.  
  21. wp_send_json_success( $results );