Opened 13 years ago
Closed 12 years ago
#4947 closed defect (bug) (fixed)
can_delete overlooked in BP_XProfile_Field::save
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 1.9 | Priority: | normal |
| Severity: | normal | Version: | 1.7 |
| Component: | Extended Profile | Keywords: | has-patch |
| Cc: |
Description
The documentation for the function xprofile_insert_field() says that can_delete is a possible parameter. However, it looks to me as though the can_delete option has been overlooked when saving XProfile field definitions in the save() method of the BP_XProfile_Field class.
I'll add a patch unless there's a reason for excluding the option that I'm unaware of.
Cheers,
Christian
Attachments (1)
Change History (8)
#4
@
13 years ago
For the record, this is my hack to set the can_delete option when creating an XProfile field programmatically:
// BuddyPress seems to overlook the 'can_delete' setting
$field = new BP_XProfile_Field( $field_id );
// let's see if our new field is correctly set
if ( $field->can_delete !== 0 ) {
// we'll need these to manually update, because the API can't do it
global $wpdb, $bp;
// construct query
$sql = $wpdb->prepare(
"UPDATE {$bp->profile->table_name_fields} SET can_delete = %d WHERE id = %d",
0,
$field_id
);
// we must have exactly one row affected
if ( $wpdb->query( $sql ) !== 1 ) {
// show error message
}
}
Hopefully that helps someone until such time as the save() method sets can_delete.
Patch to follow when I get a moment...
Cheers,
Christian
Looks like an oversight. Good catch, needle.