Using a range on a dropdown select box

BP Profile Search Using a range on a dropdown select box

  • Author
    Post
  • #12542 Reply
    Alex
    Guest

    I wanna achieve the following:
    I have a dropdown select box for users setting their height in cm. I don’t want users to be able to enter a height like 20 cm or so therefore I chose this field and not the number field.
    Unfortunately using this field in BP Search it dont offer me a range filter.
    But I would like to make it possible doing a search while setting the height from 160 to 180 cm for example.

    How can I make that work? Would I need manipulate the wordpress dropdown field saving the value in a number? But how to tell BP search using a range filter then?

    #12543 Reply
    Alex
    Guest

    Just wanna report that I found a workaround for this issue. Luckily I am using a registration plugin which maps its meta fields to the buddypress ones. So I can use a dropdown for registration and store that in a number field. The only problem left is, that I cannot allow users to change the height after registration but normally they dont shrink or get taller so it shouldn’t be a problem ?

    #12544 Reply
    andrea
    Plugin Author

    Hi Alex,

    Your solution looks good to me.

    Other solutions would involve writing a code snippet for BP Profile Search, essentially hard-coding the field ID and the allowed height values. In the end, your solution is simpler and more maintainable.

    If you wish, you could share the name of the registration plugin you are using, so other interested readers could try it. Thank you!

Reply to: Using a range on a dropdown select box
My Information