Ticket #6545: 6545.diff
| File 6545.diff, 2.7 KB (added by , 11 years ago) |
|---|
-
src/bp-xprofile/classes/class-bp-xprofile-field.php
diff --git src/bp-xprofile/classes/class-bp-xprofile-field.php src/bp-xprofile/classes/class-bp-xprofile-field.php index e061c8a..4d08bca 100644
class BP_XProfile_Field { 275 275 */ 276 276 do_action_ref_array( 'xprofile_field_before_save', array( $this ) ); 277 277 278 if ( $this->id != null ) { 278 $is_new_field = is_null( $this->id ); 279 280 if ( ! $is_new_field ) { 279 281 $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d, option_order = %d, can_delete = %d, is_default_option = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->option_order, $this->can_delete, $this->is_default_option, $this->id ); 280 282 } else { 281 283 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order, option_order, can_delete, is_default_option ) VALUES ( %d, %d, %s, %s, %s, %d, %s, %d, %d, %d, %d )", $this->group_id, $this->parent_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->option_order, $this->can_delete, $this->is_default_option ); … … class BP_XProfile_Field { 287 289 */ 288 290 if ( $wpdb->query( $sql ) !== null ) { 289 291 290 if ( ! empty( $this->id ) ) { 291 $field_id = $this->id; 292 } else { 293 $field_id = $wpdb->insert_id; 292 if ( $is_new_field ) { 293 $this->id = $wpdb->insert_id; 294 294 } 295 295 296 296 // Only do this if we are editing an existing field 297 if ( $this->id != null) {297 if ( ! $is_new_field ) { 298 298 299 299 /** 300 300 * Remove any radio or dropdown options for this … … class BP_XProfile_Field { 311 311 */ 312 312 if ( $this->type_obj->supports_options ) { 313 313 314 if ( !empty( $this->id ) ) { 315 $parent_id = $this->id; 316 } else { 317 $parent_id = $wpdb->insert_id; 318 } 314 $parent_id = $this->id; 319 315 320 316 // Allow plugins to filter the field's child options (i.e. the items in a selectbox). 321 317 $post_option = ! empty( $_POST["{$this->type}_option"] ) ? $_POST["{$this->type}_option"] : ''; … … class BP_XProfile_Field { 381 377 $this->type_obj = bp_xprofile_create_field_type( $this->type ); 382 378 $this->type_obj->field_obj = $this; 383 379 384 // If this is a new field, set the `id` property of the current object.385 if ( empty( $this->id ) ) {386 $this->id = $field_id;387 }388 389 380 return $this->id; 390 381 } else { 391 382 return false;