LLMS_Events::record_many( array[] $events = array() )

Record multiple events.


Description Description

Events are recorded with an SQL transaction. If any errors are encountered the transaction is rolled back (not events are recorded).


Top ↑

Parameters Parameters

$events

(array[]) (Optional) Array of event hashes. See LLMS_Events::record() for hash description.

Default value: array()


Top ↑

Return Return

(LLMS_Event[]|WP_Error) Array of recorded events on success or WP_Error on failure.


Top ↑

Source Source

File: includes/class-llms-events.php

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
public function record_many( $events = array() ) {
 
    global $wpdb;
    $wpdb->query( 'START TRANSACTION' );
 
    $recorded = array();
    $errors   = array();
    foreach ( $events as $event ) {
 
        $stat = $this->record( $event );
        if ( is_wp_error( $stat ) ) {
            $stat->add_data( $event );
            $errors[] = $stat;
        } else {
            $recorded[] = $stat;
        }
    }
 
    if ( count( $errors ) ) {
        $wpdb->query( 'ROLLBACK' );
        return new WP_Error( 'llms_events_record_many_errors', __( 'There was one or more errors encountered while recording the events.', 'lifterlms' ), $errors );
    }
 
    $wpdb->query( 'COMMIT' );
 
    return $recorded;
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.36.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.