Skip to:
Content
Pages
Categories
Search
Top
Bottom

creating a new profile field option on the fly : bug with parent id


  • grosbouff
    Participant

    @grosbouff

    Hi,

    I would like to create a profile field from a script.

    This profile field is a checkbox and I need to add a default option too.

    I can create the fields, but can’t set the option as child of the checkbox.

    Any idea ?

    How can I do ?

    This do not work.

    $checkbox = new BP_XProfile_Field();

    $checkbox->group_id=$location_group_id;

    $checkbox->type=’checkbox’;

    $checkbox->name=__(‘Location Marker’,’bp-maps-profile’);

    $checkbox->field_order=$key;

    $checkbox_id = $checkbox->save();

    if ($checkbox_id) {

    $option = $checkbox;

    $option->parent_id = $checkbox_id;

    $option->type=’option’;

    $option->name=__(‘Geolocate this address’,’bp-maps-profile’);

    $option->option_order=1;

    $option->order_by=’default’;

    $option->is_default_option=true;

    $option_id = $option->save();

    }else {

    $errors->add(‘bp_maps_profile_field_creation’,__( ‘Error while trying to create the map field’, ‘bp-maps-profile’ ));

    return false;

    }

  • The topic ‘creating a new profile field option on the fly : bug with parent id’ is closed to new replies.
Skip to toolbar