BBP_Admin::suggest_user()
Ajax action for facilitating the topic and reply author auto-suggest
Description
Source
File: bp-forums/admin/admin.php
public function suggest_user() { global $wpdb; // Bail early if no request if ( empty( $_REQUEST['q'] ) ) { wp_die( '0' ); } // Bail if user cannot moderate - only moderators can change authorship if ( ! current_user_can( 'moderate' ) ) { wp_die( '0' ); } // Check the ajax nonce check_ajax_referer( 'bbp_suggest_user_nonce' ); // Try to get some users $users_query = new WP_User_Query( array( 'search' => '*' . $wpdb->esc_like( $_REQUEST['q'] ) . '*', 'fields' => array( 'ID', 'user_nicename' ), 'search_columns' => array( 'ID', 'user_nicename', 'user_email' ), 'orderby' => 'ID' ) ); // If we found some users, loop through and display them if ( ! empty( $users_query->results ) ) { foreach ( (array) $users_query->results as $user ) { printf( esc_html__( '%s - %s', 'buddyboss' ), bbp_get_user_id( $user->ID ), bbp_get_user_nicename( $user->ID, array( 'force' => $user->user_nicename ) ) . "\n" ); } } die(); }
Changelog
Version | Description |
---|---|
bbPress (r5014) | 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.