0

With the module Privatemsg (v7.x-1.3) the 'To' field will show the username and then their role in brackets when composing a new message with the user id passed in the url:

/messages/new/567

I've searched the code but cannot seem to find where the role is being added so that I can disable it. Does anyone know?

  • 1
    Are you using special configuration for Privatemsg? Because I'm using the latest updated version of v7.x-1.3 and I don't see user role when composing a new message. – Aboodred1 Jun 18 '13 at 17:09
1

Inside the privatemsg module, in hook_menu search for $items['messages/autocomplete'] this is where the menu defines the auto complete path.

Search for privatemsg_autocomplete function where the output is defined.

UPDATE:

To remove just the role, here is a patch for that. Here is a thread on drupal that shows how this has progressed https://drupal.org/node/1852746

  • Are you sure this is the function that adds the role to the username? As the role is only added when the user id is passed through the url. When you enter the username directly in the 'To' field then the autocomplete looks up the username but doesn't add the role. – RebDev Jun 19 '13 at 11:39
  • I have updated my answer. – 4life Jun 19 '13 at 11:51
0

I've found what I was looking for in the file 'privatemsg.theme.inc' within this function:

function theme_privatemsg_username($variables) {
  $recipient = $variables['recipient'];
  $options = $variables['options'];
  if (!isset($recipient->uid)) {
    $recipient->uid = $recipient->recipient;
  }
  if (!empty($options['plain'])) {
    $name = check_plain(format_username($recipient));
    if (!empty($options['unique'])) {
      $name .= ' [user]';
    }   
    return $name;
  }
  else {
    return theme('username', array('account' => $recipient));
  }
}

I've just commented out the lines below which mean it won't add the text ' [user]' after the name of a user.

    // if (!empty($options['unique'])) {
    //   $name .= ' [user]';
    // }

As I'm also using the sub module 'Privatemsg roles' I've edited the file 'privatemsg_roles.module' and within this function:

function theme_privatemsg_roles_format($variables) {
  $role = $variables['recipient'];
  $options = $variables['options'];
  if (!empty($options['plain'])) {
    $name = $role->name;
    if (!empty($options['unique'])) {
      $name .= ' [role]';
    }   
    return $name;
  }
  return t('%role (role)', array('%role' => $role->name));
}

Commented out the lines below to make sure a role is always marked as such.

// if (!empty($options['unique'])) {
  $name .= ' [role]';
// }   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.