Dynamic hidden filter setting

BP Profile Search Dynamic hidden filter setting

  • Author
  • #12062 Reply


    I have a question. For my website I want to provide a member directory which is automatically based on your town.

    For example, a user sets his profile location to Rome, Italy. If he now enters the member loop, he is watching at all the users. Of course, he can filter the members with the search form, but is it possible to automatically show him only the members in his town from the beginning?

    Something like:
    [bps_directory field_99=bp_profile_field_data(‘field=99’)]

    I really appreciate your help.
    Thank you!

    #12064 Reply
    Plugin Author

    Hi Tim,

    You can add this code to your bp-custom.php file:

    add_filter ('bps_hidden_filters', 'dynamic_filters');
    function dynamic_filters ($filters)
    	$user_id = bp_loggedin_user_id ();
    	if ($user_id != 0)
    		$city = xprofile_get_field_data (99, $user_id);
    		if (!empty ($city))
    			$filters['field_99'] = $city;
    	return $filters;
Reply to: Dynamic hidden filter setting
My Information