Skip to:

custom xprofile field with options

  • AndreSC


    I’m trying to create a plugin that adds an xprofile field to allow admin to choose a custom taxonomy to use as a profile field. I’ve cribbed from the BuddyPress XProfile Image Field plugin by Alex Githatu and some of the class from the datefield xprofile class.

    I have the category open up the form for options and have a select populated by relavant values inthe xprofile fields admin screen.

    But when submiting that, validation fails with “These field options are invalid.”

    (The field is a select : <select name="field-settings[taxsel]" id ="taxsel-value" class="taxsel-value" >)

    I can’t seem to find or make sense of any documentation on how to have buddypress accept my field type option.

    Wordpress is 4.9.5, BuddyPress 2.9.4

    Any advice or pointers would be very much appreciated.

    I’m not sure what of my code to post, in the main plugin file I have
    add_filter( 'bp_xprofile_get_field_types', array( $this, 'bpxp_taxsel_field_add_field_type') );

    and in that function:

    $taxsel_field_type = array(BP_XProfile_TaxSel_Field::FIELD_TYPE_NAME => 'BP_XProfile_Field_Type_TaxSel');
    and I see the field tupe if I dump the $field_types after the array merge there.

    Thanks in advance

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

  • shanebp


    Do you have a validation function in your class?
    Something like:

    public function is_valid( $values ) {
       $this->validation_whitelist = null;
       return parent::is_valid($values);

    For a fairly simple example of adding a custom xprofile field, see BP xProfile Location
    ( yes, I know it does not yet reflect the recent changes to the Google API, but it should pass validation for your purposes )



    Thank you Shane!, will try that.




    I am trying to achieve something very similar to you, so if you are willing to share your code I’d appreciate it. No problem if not.


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