@wordplus Thank you for your time replying this issue. Is there a way to do that with other users messaging another user?
Yes, you can use same function. Just change sender and recipient to the users you need.
Thank you @wordplus !
But is it possible when I click the private message button, it will work?
Sorry if I have many questions as I’m just new in this buddypress plugin.
Plugin replace private message button automatically.
@wordplus here’s my code. my function seems to not working, are there ways to make this work? Thanks!
button submit function
——-
function mapbtn_quickmessage_button() {
echo ‘<button type=”submit” onclick=”sendQuickMessage()” title=”Send a quick message” class=”btn-message”><i class=”fa fa-comments”></i></button>’;
}
add_filter( ‘bp_before_member_header_meta’, ‘mapbtn_quickmessage_button’ );
send message function
———
function bp_messages_private_message( $user_id, $key, $user ){
if ( ! function_exists( ‘messages_new_message’ ) ) return false;
$args = array(
‘sender_id’ => bp_loggedin_user_id(), // message sender user ID
‘thread_id’ => false, // leave always false to create new thread
‘recipients’ => $user_id,
‘subject’ => ‘Hi!’, // Put here your subject
‘content’ => ‘Hi! How are you?’, // Put here your message
‘date_sent’ => bp_core_current_time()
);
$result = messages_new_message( $args );
}
add_action(‘mapbtn_quickmessage_button’, ‘bp_messages_private_message’, 10, 3);
Hi there!
What is JavaScript code you are using also?
Thanks!