BP_Messages_Notice::get_notices( array $args = array() )

Pulls up a list of notices.

Description

To get all notices, pass a value of -1 to pag_num.

Parameters

$args

(Optional) Array of parameters.

  • 'pag_num'
    (int) Number of notices per page. Defaults to 20.
  • 'pag_page'
    (int) The page number. Defaults to 1.

Default value: array()

Return

(object) List of notices to display.

Source

File: bp-messages/classes/class-bp-messages-notice.php

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
public static function get_notices( $args = array() ) {
    global $wpdb;
 
    $r = wp_parse_args( $args, array(
        'pag_num'  => 20, // Number of notices per page.
        'pag_page' => 1   // Page number.
    ) );
 
    $limit_sql = '';
    if ( (int) $r['pag_num'] >= 0 ) {
        $limit_sql = $wpdb->prepare( "LIMIT %d, %d", (int) ( ( $r['pag_page'] - 1 ) * $r['pag_num'] ), (int) $r['pag_num'] );
    }
 
    $bp = buddypress();
 
    $notices = $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC {$limit_sql}" );
 
    // Integer casting.
    foreach ( (array) $notices as $key => $data ) {
        $notices[ $key ]->id        = (int) $notices[ $key ]->id;
        $notices[ $key ]->is_active = (int) $notices[ $key ]->is_active;
    }
 
    /**
     * Filters the array of notices, sorted by date and paginated.
     *
     * @since BuddyPress 2.8.0
     *
     * @param array $r Array of parameters.
     */
    return apply_filters( 'messages_notice_get_notices', $notices, $r );
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 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.