Howto override a function in privatemsg.module? There is a function in the module private message that I want to override. What is the right way to do this?

This is the function:

/**
* Format an array of user objects.
*
* @param $part_array
*   Array with user objects, for example the one returned by
*   _privatemsg_generate_user_array.
*
* @param $limit
*   Limit the number of user objects which should be displayed.
* @param $no_text
*   When TRUE, don't display the Participants/From text.
* @return
*   String with formatted user objects, like user1, user2.
*/
function _privatemsg_format_participants($part_array, $limit = NULL,$no_text = FALSE) {
 global $user;
 if (count($part_array) &gt; 0) {
$to = array();
$limited = FALSE;
foreach ($part_array as $account) {

  // Directly address the current user.
  if (isset($account-&gt;type) &amp;&amp; in_array($account-&gt;type, array('hidden', 'user')) &amp;&amp; $account-&gt;recipient == $user-&gt;uid) {
    array_unshift($to, $no_text ? t('You') : t('you'));
    array_shift($to, $no_text ? t('You') : t('you'));
    continue;
  }

  // Don't display recipients with type hidden.
  if (isset($account-&gt;type) &amp;&amp; $account-&gt;type == 'hidden') {
    continue;
  }
  if (is_int($limit) &amp;&amp; count($to) &gt;= $limit) {
    $limited = TRUE;
    break;
  }
  $to[] = privatemsg_recipient_format($account);
}

$limit_string = '';
if ($limited) {
  $limit_string = t(' and others');
}


if ($no_text) {
  return implode(', ', $to) . $limit_string;
}

$last = array_pop($to);
if (count($to) == 0) { // Only one participant
  return t("From !last", array('!last' =&gt; $last));
}
else { // Multiple participants..
  $participants = implode(', ', $to);
  return t('Between !participants and !last', array('!participants' =&gt; $participants, '!last' =&gt; $last));
}
  }
  return '';
}


I like to remove this part from the code:

// Directly address the current user.
  if (isset($account-&gt;type) &amp;&amp; in_array($account-&gt;type, array('hidden', 'user')) &amp;&amp; $account-&gt;recipient == $user-&gt;uid) {
    array_unshift($to, $no_text ? t('You') : t('you'));
    array_shift($to, $no_text ? t('You') : t('you'));
    continue;
  }
The _privatemsg_format_participants() function is called from template_preprocess_privatemsg_recipients() function, which is a template preprocess hook. You can simply override template_preprocess_privatemsg_recipients() into your module's .module file or theme's template.php file. Check the example below:

/**
 * Implementation of hook_preprocess_privatemsg_recipients().
 */
function [MODULE/THEME_NAME]_preprocess_privatemsg_recipients(&amp;$vars) {
  $vars['participants'] = ''; // assign a default empty value
  if (isset($vars['thread']['participants'])) {
    $vars['participants'] = _[MODULE_NAME]_format_participants($vars['thread']['participants']);
  }
}

/**
 * Format an array of user objects.
 *
 * @param $part_array
 *   Array with user objects, for example the one returned by
 *   _privatemsg_generate_user_array.
 *
 * @param $limit
 *   Limit the number of user objects which should be displayed.
 * @param $no_text
 *   When TRUE, don't display the Participants/From text.
 * @return
 *   String with formatted user objects, like user1, user2.
 */
function _[MODULE_NAME]_format_participants($part_array, $limit = NULL, $no_text = FALSE) {
  global $user;
  if (count($part_array) &gt; 0) {
    $to = array();
    $limited = FALSE;
    foreach ($part_array as $account) {

      // Directly address the current user.
      if (isset($account-&gt;type) &amp;&amp; in_array($account-&gt;type, array('hidden', 'user')) &amp;&amp; $account-&gt;recipient == $user-&gt;uid) {
        array_unshift($to, $no_text ? t('You') : t('you'));
        array_shift($to, $no_text ? t('You') : t('you'));
        continue;
      }

      // Don't display recipients with type hidden.
      if (isset($account-&gt;type) &amp;&amp; $account-&gt;type == 'hidden') {
        continue;
      }
      if (is_int($limit) &amp;&amp; count($to) &gt;= $limit) {
        $limited = TRUE;
        break;
      }
      $to[] = privatemsg_recipient_format($account);
    }

    $limit_string = '';
    if ($limited) {
      $limit_string = t(' and others');
    }


    if ($no_text) {
      return implode(', ', $to) . $limit_string;
    }

    $last = array_pop($to);
    if (count($to) == 0) { // Only one participant
      return t("From !last", array('!last' =&gt; $last));
    }
    else { // Multiple participants..
      $participants = implode(', ', $to);
      return t('Between !participants and !last', array('!participants' =&gt; $participants, '!last' =&gt; $last));
    }
  }
  return '';
}


Note: Make sure to change [MODULE_NAME] with your module/theme name.