bp_ps_set_sort_options( $options )

Set BuddyBoss Profile Search sort options.

Description

Source

File: bp-core/profile-search/bps-directory.php

function bp_ps_set_sort_options ($options)
{
	global $bp_ps_sort_options;

	if (!isset ($bp_ps_sort_options))  $bp_ps_sort_options = array ();
	list (, $fields) = bp_ps_get_fields ();

	$options = explode (',', $options);
	foreach ($options as $option)
	{
		$option = trim (preg_replace ('/\s+/', ' ', $option));
		$option = explode (' ', $option);

		$code = $option[0];
		$order = isset ($option[1])? $option[1]: 'asc';

		if (!isset ($fields[$code]->sort_directory) ||
			!is_callable ($fields[$code]->sort_directory) ||
			!in_array ($order, array ('asc', 'desc', 'both')))  continue;

		if ($order == 'asc')
		{
			$bp_ps_sort_options[$code] = $fields[$code]->name;
		}
		else if ($order == 'desc')
		{
			$bp_ps_sort_options['-'. $code] = $fields[$code]->name;
		}
		else if ($order == 'both')
		{
			$bp_ps_sort_options[$code] = $fields[$code]->name. " ⇡";
			$bp_ps_sort_options['-'. $code] = $fields[$code]->name. " ⇣";
		}
	}

	add_action ('bp_members_directory_order_options', 'bp_ps_display_sort_options');
}

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.