BP Profile Search › Dynamic BPS Directory from PHP
-
AuthorPost
-
Bastian
GuestHey Andrea,
I have a question since I want to create a user specific member directory via hidden filters but I cannot hardcode them into a shortcode-widget, instead it is dependent on a user profile field.
But already starting easy with the simple following code is giving me no output:
function directory_test(){
return do_shortcode(‘[bps_directory]’);
}
add_shortcode(‘directory_test’, ‘directory_test’);Is there anything wrong with this simple approach already?
Thanks a lot for the support !
Bastian
GuestAdditionally:
Is the logic from the following page still working? It is not excluding the logged in user for me when pasting it into bp-customs.php…
andrea
Plugin AuthorHi Bastian,
Check out this topic:
https://dontdream.it/support/topic/dynamic-hidden-filter-setting/
Is this helpful? I can provide more information if you need it.
As for your second question, that code removes the current user from the search results, not from the directory. Is that what you need?
Bastian
GuestHey Andrea,
thanks a lot for the quick answer.
This works perfectly for me.Could you additionally tell me how I can apply “range” for numbers though? Unfortunately the below snippet does not work…
add_filter ('bps_hidden_filters', 'dynamic_filters'); function dynamic_filters ($filters) { $user_id = bp_loggedin_user_id (); $rooms = xprofile_get_field_data (463, $user_id); $filters['field_858_range'] = '1,' . $rooms; return $filters; }Also for testing, entering a simple ‘1,3’ does not work…
Thanks so much !
andrea
Plugin AuthorHi Bastian,
You can try:
$filters['field_858_range']['min'] = 1; $filters['field_858_range']['max'] = $rooms; -
AuthorPost