I have the following function that sends a message to selected users
function send_msg($user_id, $title, $message){
$args = array( 'recipients' => $user_id, 'sender_id' => bp_loggedin_user_id(), 'subject' => $title, 'content' => $message );
$thread_id = messages_new_message1( $args );
messages_delete_thread($thread_id,bp_loggedin_user_id());
}
This is invoked by the following code that posts the form
// Get data from form
$body_input=isset($_POST['body_input'])?$_POST['body_input']:'';
$subject_input=isset($_POST['subject_input'])?$_POST['subject_input']:'';
// Loop sending a message for each recipient
foreach(array_column($user_ids, 'user_id') as $user_N) {
send_msg($user_N, $body_input, $subject_input);
}
I want to edit the subject/title and message body before send_msg
I have tried
$args = array( 'recipients' => $user_id, 'sender_id' => bp_loggedin_user_id(), 'subject' => $title.'some text', 'content' => $message );
which does work but when I try
$args = array( 'recipients' => $user_id, 'sender_id' => bp_loggedin_user_id(), 'subject' => $title.'some text', 'content' => $message.'some text' );
It sends the message twice, one with title
and body
and another with title.what_I_append
and body.what_I_append
I have also tried this way but this does not post
$body_input=isset($_POST['body_input'])?$_POST['body_input']:''.'some text to append';
How can I correctly concatenate to the variables used for subject and body?