bp_ajax_get_suggestions()
AJAX endpoint for Suggestions API lookups.
Description
Source
File: bp-core/bp-core-functions.php
4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 | function bp_ajax_get_suggestions() { if ( ! bp_is_user_active() || empty ( $_GET [ 'term' ] ) || empty ( $_GET [ 'type' ] ) ) { wp_send_json_error( 'missing_parameter' ); exit ; } $args = array ( 'term' => sanitize_text_field( $_GET [ 'term' ] ), 'type' => sanitize_text_field( $_GET [ 'type' ] ), ); if ( ! empty ( $_GET [ 'only_friends' ] ) ) { $args [ 'only_friends' ] = absint( $_GET [ 'only_friends' ] ); } // Support per-Group suggestions. if ( ! empty ( $_GET [ 'group-id' ] ) ) { $args [ 'group_id' ] = absint( $_GET [ 'group-id' ] ); } $results = bp_core_get_suggestions( $args ); if ( is_wp_error( $results ) ) { wp_send_json_error( $results ->get_error_message() ); exit ; } wp_send_json_success( $results ); } |
Changelog
Version | Description |
---|---|
BuddyPress 2.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.