[buddypress-trac] [BuddyPress] #4105: API Request

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Fri Mar 30 00:15:54 UTC 2012


#4105: API Request
--------------------------+-----------------------------
 Reporter:  augustknight  |      Owner:
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  XProfile      |    Version:  1.5.4
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Hello, I [http://buddypress.org/community/groups/requests-
 feedback/forum/topic/api-request/ posted on the forums] and Paul
 recommended that I submit my request here.

 File: /bp-xprofile/bp-xprofile-classes.php
 Class: BP_XProfile_Group
 Function: save()

 Request:
 It would be extremely helpful (read: save me from having to hack the core)
 to have the Profile Group ID in the 'xprofile_group_after_save' action.
 Originally, I thought to just pass it in as an additional variable to the
 action, but I think the following solution is more elegant:

 {{{

 function save() {
         global $wpdb, $bp;

         $this->name        = apply_filters(
 'xprofile_group_name_before_save',        $this->name,        $this->id );
         $this->description = apply_filters(
 'xprofile_group_description_before_save', $this->description, $this->id );

         do_action_ref_array( 'xprofile_group_before_save', array( &$this )
 );

         if ( $this->id )
                 $sql = $wpdb->prepare( "UPDATE
 {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id
 = %d", $this->name, $this->description, $this->id );
         else
                 $sql = $wpdb->prepare( "INSERT INTO
 {$bp->profile->table_name_groups} (name, description, can_delete) VALUES
 (%s, %s, 1)", $this->name, $this->description );

         if ( is_wp_error( $wpdb->query( $sql ) ) )
                 return false;

         // Update the ID in the group object before calling the action
 below
         if ( ! $this->id )
                 $this->id = $wpdb->insert_id;

         do_action_ref_array( 'xprofile_group_after_save', array( &$this )
 );

         return $this->id;
 }
 }}}

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4105>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list