bp_groups_messages_new_message( array|string $args = '' )

Create New Group Message.

Description

Parameters

$args

(Optional) Array of arguments

Default value: ''

Return

(int|bool|WP_Error) ID of the message thread on success, false on failure.

Source

File: bp-templates/bp-nouveau/includes/groups/ajax.php

1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
function bp_groups_messages_new_message( $args = '' ) {
    $send = '';
    remove_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
    add_action( 'messages_message_sent', 'group_messages_notification_new_message', 10 );
 
    $r = bp_parse_args(
        $args,
        array(
            'sender_id'     => bp_loggedin_user_id(),
            'thread_id'     => false,   // False for a new message, thread id for a reply to a thread.
            'recipients'    => array(), // Can be an array of usernames, user_ids or mixed.
            'subject'       => false,
            'content'       => false,
            'date_sent'     => bp_core_current_time(),
            'append_thread' => false,
            'is_hidden'     => false,
            'mark_visible'  => false,
            'group_thread'  => true,
            'error_type'    => 'wp_error',
        ),
        'bp_groups_messages_new_message'
    );
 
    // Attempt to send the message.
    $send = messages_new_message( $r );
    remove_action( 'messages_message_sent', 'group_messages_notification_new_message', 10 );
    add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
 
    return $send;
}

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.