The functions privatemsg_new calls _privatemsg_parse_userstring to extract the duplicates in the following manner:
function privatemsg_new(&$form_state, $recipients = '', $subject = '') {
...
$to_user = _privatemsg_parse_userstring($recipient->name);
...
}
The mentioned approach does not work properly, if the realname and privatemsg_realname module is activated.
If you try to send a private message to a single user, then _privatemsg_parse_userstring will always return 0 duplicates.
$to_plain[] = privatemsg_recipient_format($recipient, array('plain' => TRUE, 'unique' => (count($to_user[2]) > 0)));
That's why "unique" will always be set to FALSE in this case.
The theme function theme_privatemsg_realname_username displays the realname without an explicit user id, if "unique" is not set:
function theme_privatemsg_realname_username($recipient, $options) {
...
$name = theme('username', $recipient, array('plain' => TRUE));
if (!empty($options['unique'])) {
$identifier = variable_get('privatemsg_realname_unique_identifier', 'name');
$name .= ' [user: ' . $recipient->$identifier . ']';
...
}
That's why the sending process will fail, in case there are more registered users with the same realname as the user you're trying to send a message to.
A possible solution would be to override (or to rewrite) the function theme_privatemsg_realname_username and check if the realname duplicates exist.
Comments
Comment #0.0
relaxy CreditAttribution: relaxy commentedphp tags
Comment #1
oadaeh CreditAttribution: oadaeh as a volunteer commentedThis issue is being closed because it is against a branch for a version of Drupal that is no longer supported.
If you feel that this issue is still valid, feel free to re-open and update it (and any possible patch) to work with the 7.x-1.x branch (bug fixes only) or the 7.x-2.x branch.
Thank you.