bbp_get_search_terms( string $passed_terms = '' )

Get the search terms

Description

Parameters

$passed_terms

(string) (Optional) Search terms

Default value: ''

Return

(bool|string) Search terms on success, false on failure

Source

File: bp-forums/search/template.php

	function bbp_get_search_terms( $passed_terms = '' ) {

		// Sanitize terms if they were passed in
		if ( !empty( $passed_terms ) ) {
			$search_terms = sanitize_title( $passed_terms );

		// Use query variable if not
		} else {
			$search_terms = get_query_var( bbp_get_search_rewrite_id() );
		}

		// Trim whitespace and decode, or set explicitly to false if empty
		$search_terms = !empty( $search_terms ) ? urldecode( trim( $search_terms ) ) : false;

		return apply_filters( 'bbp_get_search_terms', $search_terms, $passed_terms );
	}

Changelog

Changelog
Version Description
bbPress (r4579) If search terms are supplied, those are used. Otherwise check the search rewrite id query var. 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.