BP_XProfile_Group::save()
Save a profile field group.
Description Description
Return Return
(boolean)
Source Source
File: bp-xprofile/classes/class-bp-xprofile-group.php
	public function save() {
		global $wpdb;
		// Filter the field group attributes.
		$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 );
		/**
		 * Fires before the current group instance gets saved.
		 *
		 * Please use this hook to filter the properties above. Each part will be passed in.
		 *
		 * @since 1.0.0
		 *
		 * @param BP_XProfile_Group $this Current instance of the group being saved. Passed by reference.
		 */
		do_action_ref_array( 'xprofile_group_before_save', array( &$this ) );
		$bp = buddypress();
		// Update or insert.
		if ( ! empty( $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 );
		}
		// Attempt to insert or update.
		$query = $wpdb->query( $sql );
		// Bail if query fails. If `$query` is 0, it means the save was successful, but no fields were updated.
		if ( false === $query || is_wp_error( $query ) ) {
			return false;
		}
		// If not set, update the ID in the group object.
		if ( empty( $this->id ) ) {
			$this->id = $wpdb->insert_id;
		}
		/**
		 * Fires after the current group instance gets saved.
		 *
		 * @since 1.0.0
		 *
		 * @param BP_XProfile_Group $this Current instance of the group being saved. Passed by reference.
		 */
		do_action_ref_array( 'xprofile_group_after_save', array( &$this ) );
		return $this->id;
	}
			Changelog Changelog
| Version | Description | 
|---|---|
| 1.1.0 | Introduced. |