diff --git src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php
index 736c66c..fc15b2e 100644
|
|
class BP_XProfile_Field_Type_Checkbox extends BP_XProfile_Field_Type { |
104 | 104 | public function edit_field_options_html( array $args = array() ) { |
105 | 105 | $options = $this->field_obj->get_children(); |
106 | 106 | $option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $this->field_obj->id, $args['user_id'] ) ); |
| 107 | |
| 108 | /* |
| 109 | * Determine whether to pre-select the default option. |
| 110 | * |
| 111 | * If there's no saved value, take the following into account: |
| 112 | * If the user has never saved a value for this field, |
| 113 | * $option_values will be an empty string, and we should pre-select the default option. |
| 114 | * If the user has specifically chosen none of the options, |
| 115 | * $option_values will be an empty array, and we should respect that value. |
| 116 | */ |
| 117 | $select_default_option = false; |
| 118 | if ( empty( $option_values ) && ! is_array( $option_values ) ) { |
| 119 | $select_default_option = true; |
| 120 | } |
| 121 | |
107 | 122 | $option_values = ( $option_values ) ? (array) $option_values : array(); |
108 | 123 | |
109 | 124 | $html = ''; |
… |
… |
class BP_XProfile_Field_Type_Checkbox extends BP_XProfile_Field_Type { |
134 | 149 | |
135 | 150 | // If the user has not yet supplied a value for this field, check to |
136 | 151 | // see whether there is a default value available. |
137 | | if ( empty( $option_values ) && empty( $selected ) && ! empty( $options[$k]->is_default_option ) ) { |
| 152 | if ( empty( $selected ) && $select_default_option && ! empty( $options[$k]->is_default_option ) ) { |
138 | 153 | $selected = ' checked="checked"'; |
139 | 154 | } |
140 | 155 | |