bp_messages_admin_repair_unread_messages_count()
Repair unread messages count.
Description
Source
File: bp-messages/bp-messages-filters.php
function bp_messages_admin_repair_unread_messages_count() {
global $wpdb;
$offset = isset( $_POST['offset'] ) ? (int) ( $_POST['offset'] ) : 0;
$bp = buddypress();
$recipients_query = "SELECT DISTINCT thread_id FROM {$bp->messages->table_name_recipients} LIMIT 50 OFFSET $offset ";
$recipients = $wpdb->get_results( $recipients_query );
if ( ! empty( $recipients ) ) {
foreach ( $recipients as $recipient ) {
$thread_id = (int) $recipient->thread_id;
if ( ! empty( $thread_id ) ) {
$is_valid = messages_is_valid_thread( $thread_id );
if ( empty( $is_valid ) ) {
messages_delete_thread( $thread_id, bp_loggedin_user_id() );
}
}
$offset ++;
}
$records_updated = sprintf( __( '%s thread updated successfully.', 'buddyboss' ), number_format_i18n( $offset ) );
return array(
'status' => 'running',
'offset' => $offset,
'records' => $records_updated,
);
} else {
return array(
'status' => 1,
'message' => __( 'thread update complete!', 'buddyboss' ),
);
}
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.5.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.