bbp_forum_topic_reply_ajax_form_search_tags()
Search the tags that already added on forums previously and give the suggestions list.
Description
Source
File: bp-forums/functions.php
function bbp_forum_topic_reply_ajax_form_search_tags() { $response = array( 'feedback' => sprintf( '<div class="bp-feedback error bp-ajax-message"><span class="bp-icon" aria-hidden="true"></span><p>%s</p></div>', esc_html__( 'There was a problem performing this action. Please try again.', 'buddyboss' ) ), ); // Bail if not a POST action.. if ( ! bp_is_get_request() ) { wp_send_json_error( $response ); } if ( empty( $_GET['_wpnonce'] ) ) { wp_send_json_error( $response ); } // Use default nonce. $nonce = $_GET['_wpnonce']; $check = 'search_tag'; // Nonce check!. if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, $check ) ) { wp_send_json_error( $response ); } if ( empty( $_GET['term'] ) ) { wp_send_json_error( $response ); } // WP_Term_Query arguments. $args = array( 'taxonomy' => array( 'topic-tag' ), 'search' => $_GET['term'], 'hide_empty' => false, ); // The Term Query. $term_query = new WP_Term_Query( $args ); $tags = array(); // The Loop. if ( ! empty( $term_query ) && ! is_wp_error( $term_query ) ) { $tags = $term_query->terms; } if ( empty( $tags ) ) { $tags = array(); } wp_send_json_success( array( 'results' => array_map( function( $result ) { return array( 'id' => $result->slug, 'text' => $result->name, ); }, $tags ), ) ); }
Changelog
Version | Description |
---|---|
BuddyBoss 1.1.9 | 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.