displaying autocomplete

BP Profile Search › displaying autocomplete

  • Author
    Post
  • #11154 Reply
    Clara
    Guest

    Hello Andrea,

    I would like to display a field that is autocomplete for internal taxonomies. I tried combining your plugin with BuddyPress Xprofile Custom Field Types. It looks like they have an autocomplete taxonomies option, but I couldn’t even make sure of it because your plugin won’t allow me to display the custom taxonomy field.
    Is there a way to display that kind of field using your plugin?

    Thank you so much for the organised plugin page that you have 🙂

    Clara

    #11155 Reply
    andrea
    Plugin Author

    Hello Clara,

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

    I’ve received many request on this topic, so I’m going to write a tutorial on the integration of taxonomy field types.

    Please let me know if you have more questions!

    #11213 Reply
    andrea
    Plugin Author

    Hello Clara,

    As promised, I wrote a post explaining how to register a Custom Taxonomy Multiselector field, and another post explaining how to add Select2 to your search forms, without having to write a new form template.

    If you apply both, you could achieve the purpose you detailed in your original post.

    https://dontdream.it/taxonomy-search/
    https://dontdream.it/enabling-select2/

    Please let me know if something doesn’t work for you as expected!

    #11215 Reply
    Clara
    Guest

    Hello Andrea,

    I didn’t have time to reply to your previous answer.
    I am moving so lots of boxes everywhere. I will try this tutorial you’ve done, I am very excited to see it working!
    Thank you so much!!!!

    #11217 Reply
    Clara
    Guest

    Hi Andrea,

    I didn’t find the file bp-custom.php.
    What Am I doing wrong?

    #11218 Reply
    andrea
    Plugin Author

    Hi Clara,

    If you don’t have a bp-custom.php file, you can create it under wp-content/plugins.

    See https://codex.buddypress.org/themes/bp-custom-php/

    #11277 Reply
    Clara
    Guest

    Hello Andrea,

    Thank you so much for your messages and your help.
    I have read all the links you’ve sent to me. I have tested and it didn’t work 🙁
    I created a bp-custom.php file and uploaded in wp-content/plugins.
    In the file I pasted the code
    <?php
    use BPXProfileCFTR\Field_Types\Field_Type_Multi_Select_Taxonomy;
     
    add_action (‘bps_custom_field’, ‘bps_register_msct’);
    add_action (‘bp_ps_custom_field’, ‘bps_register_msct’);
    function bps_register_msct ($f)
    {
    if ($f->type != ‘multiselect_custom_taxonomy’) return;
     
    $taxonomy = Field_Type_Multi_Select_Taxonomy::get_selected_taxonomy ($f->id);
    $terms = get_terms ($taxonomy, array (‘hide_empty’ => false));
     
    $f->format = ‘set’;
    $f->get_value = ”;
    foreach ($terms as $t)
    $f->options[$t->term_id] = $t->name;
    }
     
    add_action (‘bps_field_before_search_form’, ‘bps_change_display’);
    add_action (‘bp_ps_field_before_search_form’, ‘bps_change_display’);
    function bps_change_display ($f)
    {
    if (isset ($f->type) && $f->type == ‘multiselect_custom_taxonomy’)
    $f->display = ‘multiselectbox’;

    add_action (‘bps_before_search_form’, ‘bps_enable_select2’);
    add_action (‘bp_ps_before_search_form’, ‘bps_enable_select2’);
    function bps_enable_select2 ($F)
    {
    wp_enqueue_script (‘select2-js’, ‘https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js&#8217;, array (‘jquery’));
    wp_enqueue_style (‘select2-css’, ‘https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css&#8217;);
    ?>
    <script>
    jQuery(function ($) {
    $(‘.bps-selectbox select’).select2({width: ’10em’, dropdownAutoWidth: true});
    $(‘.bps-multiselectbox select’).select2({width: ’10em’, dropdownAutoWidth: true});
    });
    </script>

    ?>

    What happens is that I get a message on the browser saying that my site has a critical error and I can’t access anything, nor dashboard, the site breaks.

    Have I done anything wrong?

    #11279 Reply
    andrea
    Plugin Author

    Hello Clara,

    To see which error you are getting, you could temporarily set WP_DEBUG to true in your wp-config.php.

    If you prefer, I could take a look at your site. I’ll need a WP admin access, and you can share it privately using my Contact page.

    #11291 Reply
    andrea
    Plugin Author

    Hello Clara,

    I was able to log into your site, and there were a few missing characters in bp-custom.php, e.g. a couple of closing braces }.

    They are also missing in the code you pasted above, but I didn’t notice them earlier.

    Please let me know if the autocomplete feature is now working for you.

    #11292 Reply
    Clara
    Guest

    Hello Andrea,

    YES it works!! The autocomplete display works together only with the Custom Taxonomy MultiSelector, which works with only with categories as for taxonomy. Is that correct? That works perfectly fine for me.
    I am just making sure I am aware of my possibilities.

    I can’t thank you enough for this help.
    Do you have account on Fiverr? Maybe we can work together next time I need help, in a proper way.

    Thank you!
    clara

    #11293 Reply
    andrea
    Plugin Author

    Hi Clara,

    You’re welcome!

    Yes, Select2 autocomplete applies to Custom Taxonomy MultiSelector and any other multiple-selection fields you may create, while Custom Taxonomy MultiSelector applies to categories and any other taxonomy you may create.

    #11511 Reply
    Clara
    Guest

    Hi Andrea!

    I wanted to forward to you an email from WP all import plugin support.
    Where do I send it to?

    I am planning to have 500+ items in that Multi Select Box field.
    That would be a lot of work to do it manually.

    I’ve contacted WP all import to check if they know the cusom field name for that field. They replied like this:

    “Unfortunately, BuddyPress uses custom database tables (https://d.pr/i/W6xCr0) which aren’t supported by our plugin out of the box. Those custom field types would be stored there.

    You’ll need to write custom PHP code (see documentation) that uses our API (see documentation) to import all values into this plugin correctly.

    While I don’t have an example snippet to offer, one of our recommended developers should be able to help: https://www.wpallimport.com/developers/.

    Hopefully, that helps, but let us know if you have any other questions.”

    So, if you don’t have any other idea on how to achieve this, I am considering paying for a developer to get that custom field integrated in the WpAll import plugin, so we can import values to your fields.

    Is that any of interest to you?

    Kind regards,
    Clara

    #11512 Reply
    andrea
    Plugin Author

    Hi Clara,

    If you are still using a Custom Taxonomy MultiSelector, what you actually need to import is a taxonomy, the same that you are using in your Custom Taxonomy MultiSelector field.

    I think that WP All Import can import taxonomies, but you might want to double check with them just to be sure.

    #11518 Reply
    Clara
    Guest

    Andrea,

    You made me feel very stupid 😀
    WHY didn’t I think of that before… I was going for Multi Select Box field…! And now changed to Custom Taxonomy MultiSelector and uploaded just normal categories via WP all import. It worked! Obviously! Doh! lol

    THANK YOU
    Clara

    #11519 Reply
    andrea
    Plugin Author

    Hi Clara,

    That’s great! I’m glad you have successfully imported your data, and that’s what really matters 🙂

    #11522 Reply
    Clara
    Guest

    Hi again Andrea… 😀
    I hope you’re not tired of me yet! 🙂

    I am struggling with displaying autocomplete using the google API when working with location field.

    The autocomplete works only if I choose location with “distance” in serach mode.
    But then the distance ratio is required. Which is not optimal.

    I would like to have location and maybe “contains” as search mode, so the kilometers ratio field disappears.
    But then the list of google places don’t show up.

    Any idea?

    #11525 Reply
    andrea
    Plugin Author

    Hi Clara,

    Unfortunately using contains with Google place autocomplete is not possible at this time, but I’m going to add this feature to my to-do list. Thank you for your suggestion!

    #11526 Reply
    Clara Mendes
    Guest

    Ah ok!
    Then I know.
    Please let me know if that feature comes up as I will be very interested! 🙂
    Thank you Andreas

Reply to: displaying autocomplete
My Information