[buddypress-trac] [BuddyPress] #4947: can_delete overlooked in BP_XProfile_Field::save

buddypress-trac noreply at wordpress.org
Tue Apr 30 12:28:14 UTC 2013


#4947: can_delete overlooked in BP_XProfile_Field::save
--------------------------+-----------------------------
 Reporter:  needle        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  XProfile      |     Version:  1.7
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+-----------------------------

Comment (by needle):

 For the record, this is my hack to set the `can_delete` option when
 creating an XProfile field programmatically:

 {{{#!php
 // 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

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4947#comment:4>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list