How to insert a link in a private message by code? I am sending a message to some users when a specific function is created. However, the content of the message that I send is always in plain text, meaning that it does not render links. What can I do?

This is the function that I use:

$message="A user has requested to join your group ".$group-&gt;title.". You can go to the group's page now to approve or decline their request.";

privatemsg_new_thread(array($user), 'New membership request for '.$group-&gt;title, $message);


I would this to work:

$message="A user has requested to join your group ".l($group-&gt;title,'group/'.$group-&gt;gid).". You can go to the group's page now to approve or decline their request.";


Any suggestions?
This is how I do it: 

function _send_notifications($entity, $recipient) {
    $params = set_params($recipient, $entity);
    $sent = privatemsg_new_thread(array($recipient), $params['message_subject'], trim(token_replace($params['message_body']))); 
}

function set_params($account, $entity) {
    if (isset($entity-&gt;nid) &amp;&amp; $entity-&gt;type == 'entity_type') {
        $author = user_load($entity-&gt;uid); // Load the node author.
        $params = array(
            '!first_name' =&gt; $account-&gt;field_first_name[LANGUAGE_NONE][0]['value'],
            '!last_name' =&gt; $account-&gt;field_last_name[LANGUAGE_NONE][0]['value'],
            '!node_type' =&gt; drupal_ucfirst(str_replace('_', ' ', $entity-&gt;type)),
            '!node_title' =&gt; $entity-&gt;title,
            '!node_url' =&gt; url(drupal_get_path_alias('node/' . $entity-&gt;nid), array('absolute' =&gt; TRUE)),
        );
        $data['message_subject'] = t('New node type has been created');
        $data['message_body'] = t(
            "Dear !first_name !last_name,\na new !node_type has been posted with the title \"!node_title\".\n\nYou can view the post here:\n!node_url\n\n--  [site:name] team", $params
        );

    return $data;
}