BuddyDev

Search

Conditional Profile Fields for BuddyPress

  • Participant
    Level: Initiated
    Posts: 4
    Bharat on #33330

    I found bug in Conditional Profile Fields for BuddyPress plugin.

    foreach ( $related_fields['conditions'] as $condition ) {

    // check if condition is matched.
    if ( $this->is_match( $data, $condition['value'], $condition['operator'] ) ) {

    // if visibility is set to hidden and condition matched,
    // delete data for the field on which this condition is applied.
    if ( $condition['visibility'] === 'hide' ) {
    xprofile_delete_field_data( $condition['field_id'], $user_id );
    }
    } else {
    // if there is no match and the visibility is set to show on condition,
    // we still need to delete the data for the field on which this condition is applied.
    if ( $condition['visibility'] === 'show' ) {
    xprofile_delete_field_data( $condition['field_id'], $user_id );
    }
    }
    }

  • Participant
    Level: Initiated
    Posts: 4
    Bharat on #33331

    I think your deteting xprofile_delete_field_data data in show condition.

  • Keymaster
    (BuddyDev Team)
    Posts: 24638
    Brajesh Singh on #33332

    Please see the comment above that line.

    
    // if there is no match and the visibility is set to show on condition,
    // we still need to delete the data for the field on which this condition is applied.
    

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Bharat on #33334

    Yes there is match show visisblity and I’ve set value from backend show visibility if ( $condition[‘visibility’] === ‘show’ ).

    You can test with default WordPress and when you save profile field which are not updating.

  • Keymaster
    (BuddyDev Team)
    Posts: 24638
    Brajesh Singh on #33342

    Hi Bharat,
    It seems to me the code is correct.

    what we are doing is: If a condition does not match and the field is set to be visible, we remove the data for that field. It is opposite of if a field matches as the field is set to hidde.

    I haven’t tested recently, if you are insisting, Will test and post tomorrow.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 4
    Bharat on #33351

    okay you can test and you will get better idea.

You must be logged in to reply to this topic.

This topic is: not resolved