Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 11 years ago

#4947 closed defect (bug) (fixed)

can_delete overlooked in BP_XProfile_Field::save

Reported by: needle's profile needle Owned by: boonebgorges's profile boonebgorges
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)

bp-xprofile-can-delete.patch (2.2 KB) - added by needle 11 years ago.
saves can_delete option

Download all attachments as: .zip

Change History (8)

#1 @boonebgorges
11 years ago

Looks like an oversight. Good catch, needle.

#2 @DJPaul
11 years ago

  • Milestone changed from Awaiting Review to BuddyPress.org

#3 @DJPaul
11 years ago

  • Milestone changed from BuddyPress.org to Future Release

#4 @needle
11 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

@needle
11 years ago

saves can_delete option

#5 @needle
11 years ago

  • Keywords has-patch added

#6 @boonebgorges
11 years ago

  • Milestone changed from Future Release to 1.9

#7 @boonebgorges
11 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7419:

Respect can_delete setting when saving profile field

Fixes #4947

Props needle

Note: See TracTickets for help on using tickets.