Support » Plugin: BP Profile Search » Register taxonomy to use in search

  • Hi, I’m trying to register taxonomies created with toolset types with both custom profile fields, which I’ve done, and then with your profile search. I’ve seen the below, can I just confirm the use?

    http://dontdream.it/bp-profile-search/custom-profile-field-types/

    For instance, if I have the taxonomy ‘House Features’ with terms ‘Garden’, ‘Shed’ and ‘Terrace’ what would this code look like:

    add_action ('bps_custom_field', 'my_hook02');
    function my_hook02 ($f)
    {
        if ($f->type != 'my_custom_type')  return;
    
        // submit the format of my_custom_type
        $f->format = 'text';
    
        // submit the field options, if they are not stored in
        // the standard (wp_)bp_xprofile_fields table
        $f->options = array (0 => 'Male', 1 => 'Female');
    
        // submit the search function, if the field values are not
        // stored in the standard (wp_)bp_xprofile_data table
        $f->search = 'my_search_function';
    }
    
    function my_search_function ($f)
    {
        $filter = $f->filter;    // the current search mode
        $value = $f->value;      // the value(s) POSTed by the search form
    
        $results = ...           // array of matching user IDs
        return $results;
    }

    And can I also check, would the results be that in the search form, once it’s registered, the user checks which terms they would like to search for under that taxonomy, and users who have checked those terms as applying, will appear?

    Thank you

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hello Kir,

    One question, I guess that the taxonomy House Features applies to a custom post type that represents a house, is that right?

    Hi, in this case it’s about Buddypress user profiles, so say for example if each ‘BP user profile’ were a ‘house’ – and that each house (or BP profile) – had a taxonomy of ‘House Features’ applied to it, with the above terms Shed, Garden and Terrace.

    I’ve added a list of taxonomies as above, with terms, to my buddypress profiles so that at reg the user can complete the data. I now wish to make them searchable using the Profile Search plugin, but when I go to add them I can’t find an appropriate field.

    It is my understanding so far that I will need to register each taxonomy and its terms with BP Profile in order to have that field appear for use when producing my search form, using the code at your site linked above – however I’m not clear on how to use the code properly so I was hoping you could give me an example, using the example above, (of what the code should look like if I were adding that taxonomy house features, with those three terms shed, terrace and garden) – so it’s clearer for me what I need to do to get it working and I can replicate it for each taxonomy I need to add a field to the search form for, so that my users can search for all of the profiles who have said that certain taxonomies (which i’m using elsewhere in the site too) apply to them.

    So if a BP profile is registered and marks that the under the tax House Features the terms Garden and Terrace apply to them, in the search I want to have that tax pop up with a multi-select box, or check boxes perhaps (as long as they’re based on ‘and’ not ‘or’) so that the site user can search for which profiles are filed under which terms under said taxonomy.

    I hope that helps! 🙂
    Thank you
    K

    Oops, that should have said:

    “It is my understanding so far that I will need to register each taxonomy and its terms with BP PROFILE SEARCH”

    (I missed the ‘Search’ off – sorry! I want to be clear on what I’m talking about)

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hello Kir,

    If your House Features is a user taxonomy (as opposed to a post taxonomy or a custom post taxonomy), when you click Add Field in the BP Profile Search Edit Form page you should find it under the User Taxonomies options group, at the bottom of the drop-down list. Is it there?

    Hi no it’s not there I’m afraid, hence the request for help

    In fact I don’t even have an option for user taxonomies when I add a field?

    Only users data and user meta data and it’s not in either of those?

    I checked and everything’s up to date? Should there be a section called user taxonomies when you add a field then?

    Plugin Author Andrea Tarantini

    (@dontdream)

    Probably I can suggest a workaround.

    In my opinion, House Features doesn’t need to be a taxonomy, but can be a standard BuddyPress profile field, that you can create under Users => Profile Fields => Add New Field as a Drop Down Select Box field type.

    As soon as you do that, the field will be automatically available to BP Profile Search. Is this a viable alternative?

    Hi thank you, but my thinking was that these many taxonomies (and their many terms) exist already in my site, and are employed all around it already – applied to custom posts.

    I’d have to replicate every tax and all of its terms as a profile field for this work around, so it wouldn’t really be ideal.

    Also I then planned to create a search of both the user tables as well as the custom post types for the same set of taxonomies (because as it stands, users and custom post have the same set of taxonomies applied to them). I wouldn’t be able to do that with this work around.

    Is there a reason that user taxonomies might not be showing up for me?

    Plugin Author Andrea Tarantini

    (@dontdream)

    I’m afraid I missed a bit in your original post, where you say you are using a taxonomy as a custom profile field. Are you using BuddyPress Xprofile Custom Field Types for that?

    Well they’re produced in Toolset Types originally, however yes I’m using them in BuddyPress Xprofile Custom Field Types, and have added them to the BP user profiles via that plugin, so yes.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi Kir,

    BuddyPress Xprofile Custom Field Types supports integration with BP Profile Search, but not for all the custom field types. The Custom Taxonomy Selector is one of the unsupported types.

    I suggest you contact the BuddyPress Xprofile Custom Field Types team, they are very responsive in my experience, and may add support for the unsupported types.

    Alternatively, you can try to add support yourself. As you correctly noted, the code template is provided in

    http://dontdream.it/bp-profile-search/custom-profile-field-types/

    but filling in the details requires a thorough knowledge of the BuddyPress Xprofile Custom Field Types internals, that I don’t have at this moment. Anyway I’m 100% available to provide explanations on the BP Profile Search side.

    Hi there! Ah ok I see, thank you, well I’ve taken your advice and asked the guys at the plugin, I’ve given them all of the info and linked this thread so fingers crossed! 😀

    Here’s the info

    Thank you

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.