bp_search_form_type_select()

Generate the basic search form as used in BP-Default’s header.

Description

Return

(string) HTML <select> element.

Source

File: bp-core/bp-core-template.php

function bp_search_form_type_select() {

	$options = array();

	if ( bp_is_active( 'xprofile' ) ) {
		$options['members'] = __( 'Members', 'buddyboss' );
	}

	if ( bp_is_active( 'groups' ) ) {
		$options['groups']  = __( 'Groups', 'buddyboss' );
	}

	if ( bp_is_active( 'blogs' ) && is_multisite() ) {
		$options['blogs']   = __( 'Blogs', 'buddyboss' );
	}

	$options['posts'] = __( 'Posts', 'buddyboss' );

	// Eventually this won't be needed and a page will be built to integrate all search results.
	$selection_box  = '<label for="search-which" class="accessibly-hidden">' . __( 'Search these:', 'buddyboss' ) . '</label>';
	$selection_box .= '<select name="search-which" id="search-which" style="width: auto">';

	/**
	 * Filters all of the component options available for search scope.
	 *
	 * @since BuddyPress 1.5.0
	 *
	 * @param array $options Array of options to add to select field.
	 */
	$options = apply_filters( 'bp_search_form_type_select_options', $options );
	foreach( (array) $options as $option_value => $option_title ) {
		$selection_box .= sprintf( '<option value="%s">%s</option>', $option_value, $option_title );
	}

	$selection_box .= '</select>';

	/**
	 * Filters the complete <select> input used for search scope.
	 *
	 * @since BuddyPress 1.0.0
	 *
	 * @param string $selection_box <select> input for selecting search scope.
	 */
	return apply_filters( 'bp_search_form_type_select', $selection_box );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.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.