BP Profile Search › Apply filter automatically from stored preferences
-
AuthorPost
-
RajeshGuest
I’m making a dating site. I store preferences and then show users with matching fields. Is it possible to supply the fields to this plugin? Any hooks available?
andreaPlugin AuthorHi Rajesh,
As you may know, you can add hidden filters to a directory, see:
C) Add hidden filters to a member directory
in:
https://dontdream.it/bp-profile-search/custom-directories/
For instance if you want to show only members whose birthplace (say birthplace is field 23) contains ‘USA’, you can use the shortcode:
[bps_directory field_23_contains=’USA’]
This is a static filter. If, as in your case, you need dynamic filters you can use the ‘bps_hidden_filters’ hook:
add_filter ('bps_hidden_filters', 'add_hidden_filters'); function add_hidden_filters ($filters) { $filters['field_23_contains'] = 'USA'; return $filters; }
As it is, this is still a static filter. In your case you should replace ‘field_23_contains’ and ‘USA’ with the stored preferences of your current logged-in user.
RajeshGuestThank you very much for your reply and your patience
RajeshGuestWith hidden fields it is becoming a static directory of certain users, instead, I want users to be able to change their preferences. Is it possible without hidden fields?
Thank you.andreaPlugin AuthorHi Rajesh,
The code I provided, as it is, is a static filter. You should modify it, adding code to replace ‘field_23_contains’ and ‘USA’ with the current stored preferences of your logged-in user.
If your users change their stored preferences, the hidden filters will change accordingly. Does this happen in your case?
-
AuthorPost