Opened 13 years ago
Closed 13 years ago
#4105 closed enhancement (fixed)
Include profile group ID in xprofile_group_after_save filter
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 1.6 | Priority: | low |
Severity: | normal | Version: | 1.5.4 |
Component: | Extended Profile | Keywords: | has-patch |
Cc: |
Description
Hello, I 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; }
Change History (5)
Note: See
TracTickets for help on using
tickets.
(In [5961]) Make sure ID property is set in Group object when Group is saved. Fixes #4105, props augustknight