Skip to:
Content
Pages
Categories
Search
Top
Bottom

Dynamically populate xprofile select box


  • Daryll Doyle
    Participant

    @enshrined

    I’m trying to populate an xprofile select box using the values of a custom post type.

    E.G.

    Custom post type called colours with posts: red, green and blue

    I then want an xprofile field ‘favourite colour’ to list red, green and blue.

    When I add yellow to the colours post type, I’d like that automatically added to the xprofile select box.

    My issue is that I can’t seem to find which filter I need to do this or whether I need to create a new xprofile field type?

    Any help would be gratefully appreciated.

    Cheers,
    Daryll

Viewing 2 replies - 1 through 2 (of 2 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    Hi Daryll,
    Your best bet is creating a new xprofile field type and extend select filed type.

    It is a code I had written around a year ago for some client, but this may point you into the direction. It is for country list.

    https://gist.github.com/sbrajesh/5b3f4fd44c9c91b3ed3e

    All you need to do is extend the select field and override 3 methods

    is_valid(),
    display_filter()
    and edit_field_options_html()

    I did a little more as I wanted the same field type to allow single/multi selection both.

    Hope that helps.


    Daryll Doyle
    Participant

    @enshrined

    Hi Brajesh,

    That’s amazing, thanks for your help and for the demo code 🙂

    Cheers,
    Daryll

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dynamically populate xprofile select box’ is closed to new replies.
Skip to toolbar