Moodle php code : To send message

send a message from one user to another user

// from user : user object
// to user user object
$message = 'test';

$messageid = message_post_message($fromuser, $sendto, $message, 0);

// if you want to send message to an existing conversation
// conversation id
$messageobject  = \core_message\api::send_message_to_conversation($fromuser->id, $conversationid, $message, 0);
            

Leave a Reply

Your email address will not be published. Required fields are marked *