Skip to:

Opened 11 years ago

Closed 11 years ago

#4105 closed enhancement (fixed)

Include profile group ID in xprofile_group_after_save filter

Reported by: augustknight's profile augustknight Owned by: djpaul's profile DJPaul
Milestone: 1.6 Priority: low
Severity: normal Version: 1.5.4
Component: Extended Profile Keywords: has-patch


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()

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 );
		$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)

#1 @DJPaul
11 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 1.6
  • Priority changed from normal to low

#2 @boonebgorges
11 years ago

  • Keywords has-patch added; needs-patch removed

#3 @boonebgorges
11 years ago

  • Summary changed from API Request to Include profile group ID in xprofile_group_after_save filter

#4 @DJPaul
11 years ago

  • Owner set to DJPaul
  • Status changed from new to assigned

#5 @djpaul
11 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [5961]) Make sure ID property is set in Group object when Group is saved. Fixes #4105, props augustknight

Note: See TracTickets for help on using tickets.