BP_Invitation::save()

Update or insert invitation details into the database.

Description

Return

(bool) True on success, false on failure.

Source

File: bp-core/classes/class-bp-invitation.php

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
public function save() {
 
    // Return value
    $retval = false;
 
    // Default data and format
    $data = array(
        'user_id'           => $this->user_id,
        'inviter_id'        => $this->inviter_id,
        'invitee_email'     => $this->invitee_email,
        'class'             => sanitize_key( $this->class ),
        'item_id'           => $this->item_id,
        'secondary_item_id' => $this->secondary_item_id,
        'type'              => $this->type,
        'content'           => wp_kses( wp_unslash( $this->content ), array() ),
        'date_modified'     => $this->date_modified,
        'invite_sent'       => $this->invite_sent,
        'accepted'          => $this->accepted,
    );
    $data_format = array( '%d', '%d', '%s', '%s', '%d', '%d', '%s', '%s', '%s', '%d', '%d' );
 
    /**
     * Fires before an invitation is saved.
     *
     * @since BuddyBoss 1.3.5
     *
     * @param BP_Invitation object $this Characteristics of the invitation to be saved.
     */
    do_action_ref_array( 'bp_invitation_before_save', array( &$this ) );
 
    // Update
    if ( ! empty( $this->id ) ) {
        $result = self::_update( $data, array( 'ID' => $this->id ), $data_format, array( '%d' ) );
    // Insert
    } else {
        $result = self::_insert( $data, $data_format );
    }
 
    // Set the invitation ID if successful
    if ( ! empty( $result ) && ! is_wp_error( $result ) ) {
        global $wpdb;
 
        $this->id = $wpdb->insert_id;
        $retval   = $wpdb->insert_id;
    }
 
    wp_cache_delete( $this->id, 'bp_invitations' );
 
    /**
     * Fires after an invitation is saved.
     *
     * @since BuddyBoss 1.3.5
     *
     * @param BP_Invitation object $this Characteristics of the invitation just saved.
     */
    do_action_ref_array( 'bp_invitation_after_save', array( &$this ) );
 
    // Return the result
    return $retval;
}

Changelog

Changelog
Version Description
BuddyBoss 1.3.5 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.