Search by User Meta Data

User meta data are data in the (wp_)usermeta table.

This table contains a variety of data, e.g. the user’s first and last name, user roles, and many others, added by WordPress core or by plugins.

Out of the box, BP Profile Search supports only a handful of user meta data: first_name, last_name, role, total_friend_count, total_group_count.

To add your favorite user meta data to that basic initial list, use the ‘bps_usermeta_keys’ filter hook, as follows:

add_filter ('bps_usermeta_keys', 'add_more_keys');
function add_more_keys ($keys)
{
// to add a key:
//
// $keys['meta_key'] = 'format';
//
// 'meta_key' is the meta_key from the usermeta table
// 'format' is one of: text, integer, decimal, date, set

	$keys['nickname'] = 'text';

// if a meta has options, specify them too

	$options = array (0 => 'Male', 1 => 'Female');
	$keys['gender'] = array ('text', $options);

// add as many keys as needed, then:

	return $keys;
}