messages_screen_inbox()

Load the Messages > Inbox screen.

Description

Source

File: bp-messages/screens/inbox.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function messages_screen_inbox() {
 
    if ( bp_action_variables() ) {
        bp_do_404();
        return;
    }
 
    // check if user has threads or not, if yes then redirect to latest thread otherwise to compose screen
    if ( bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) {
        $thread_id = 0;
        while ( bp_message_threads() ) : bp_message_thread();
            $thread_id = bp_get_message_thread_id();
            break;
        endwhile;
 
        if ( $thread_id ) {
            wp_safe_redirect( bp_get_message_thread_view_link( $thread_id ) );
            exit;
        }
    } else {
        wp_safe_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/compose' ) );
        exit;
    }
 
    /**
     * Fires right before the loading of the Messages inbox screen template file.
     *
     * @since BuddyPress 1.0.0
     */
    do_action( 'messages_screen_inbox' );
 
    /**
     * Filters the template to load for the Messages inbox screen.
     *
     * @since BuddyPress 1.0.0
     *
     * @param string $template Path to the messages template to load.
     */
    bp_core_load_template( apply_filters( 'messages_template_inbox', 'members/single/home' ) );
}

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.