Apply filter automatically from stored preferences

BP Profile Search Apply filter automatically from stored preferences

  • Author
    Post
  • #12204 Reply
    Rajesh
    Guest

    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?

    #12205 Reply
    andrea
    Plugin Author

    Hi 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.

    #12206 Reply
    Rajesh
    Guest

    Thank you very much for your reply and your patience

    #12207 Reply
    Rajesh
    Guest

    With 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.

    #12208 Reply
    andrea
    Plugin Author

    Hi 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?

Reply to: Apply filter automatically from stored preferences
My Information