messages_action_delete_message()

Process a request to delete a message.

Description

Return

(bool) False on failure.

Source

File: bp-messages/actions/delete.php

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function messages_action_delete_message() {
 
    if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'delete', 0 ) ) {
        return false;
    }
 
    $thread_id = bp_action_variable( 1 );
 
    if ( !$thread_id || !is_numeric( $thread_id ) || !messages_check_thread_access( $thread_id ) ) {
        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
    } else {
        if ( ! check_admin_referer( 'messages_delete_thread' ) ) {
            return false;
        }
 
        // Delete message.
        if ( !messages_delete_thread( $thread_id ) ) {
            bp_core_add_message( __('There was an error deleting that message.', 'buddyboss'), 'error' );
        } else {
            bp_core_add_message( __('Message deleted.', 'buddyboss') );
        }
        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
    }
}

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.