Opened 13 years ago
Closed 13 years ago
#4947 closed defect (bug) (fixed)
can_delete overlooked in BP_XProfile_Field::save
| Reported by: | needle | Owned by: | boonebgorges |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.9 |
| Component: | Extended Profile | Version: | 1.7 |
| Severity: | normal | 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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Looks like an oversight. Good catch, needle.