Bp_Search_Members::print_search_options( $items_to_search )

What fields members should be searched on? Prints options to search through username, email, nicename/displayname.

Description

Prints xprofile fields, if xprofile component is active.

Source

File: bp-search/classes/class-bp-search-members.php

		function print_search_options( $items_to_search ){
			echo "<div class='wp-user-fields' style='margin: 10px 0 0 30px'>";
			echo "<p class='xprofile-group-name' style='margin: 5px 0'><strong>" . __('Account','buddyboss') . "</strong></p>";

			$fields = array(
				'user_login'	=> __( 'Username/Login', 'buddyboss' ),
				'display_name'	=> __( 'Display Name', 'buddyboss' ),
				'user_email'	=> __( 'Email', 'buddyboss' ),
				'user_meta'     => __( 'User Meta', 'buddyboss' )
			);
			foreach( $fields as $field=>$label ){
				$item = 'member_field_' . $field;
				$checked = !empty( $items_to_search ) && in_array( $item, $items_to_search ) ? ' checked' : '';
				echo "<label><input type='checkbox' value='{$item}' name='bp_search_plugin_options[items-to-search][]' {$checked}>{$label}</label><br>";
			}

			echo "</div><!-- .wp-user-fields -->";

			if( !function_exists( 'bp_is_active' ) || !bp_is_active( 'xprofile' ) )
				return;

			$groups = bp_xprofile_get_groups( array(
				'fetch_fields' => true
			) );

			if ( !empty( $groups ) ){
				echo "<div class='xprofile-fields' style='margin: 0 0 10px 30px'>";
				foreach ( $groups as $group ){
					echo "<p class='xprofile-group-name' style='margin: 5px 0'><strong>" . $group->name . "</strong></p>";

					if ( !empty( $group->fields ) ){
						foreach ( $group->fields as $field ) {
							//lets save these as xprofile_field_{field_id}
							$item = 'xprofile_field_' . $field->id;
							$checked = !empty( $items_to_search ) && in_array( $item, $items_to_search ) ? ' checked' : '';
							echo "<label><input type='checkbox' value='{$item}' name='bp_search_plugin_options[items-to-search][]' {$checked}>{$field->name}</label><br>";
						}
					}
				}
				echo "</div><!-- .xprofile-fields -->";
			}
		}

Changelog

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