Skip to main content
Bounty Ended with 100 reputation awarded by Patrick Kenny
added 61 characters in body
Source Link
kalabro
  • 7.9k
  • 35
  • 46

I really don't know why you don't like the answer by Rene.

Let me show a more detailed example. You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':
enter image description here
You can edit Flag labels, link type and permissions here.
The result:
enter image description here

Please, feel free to ask questions.

I really don't know why you don't like the answer by Rene.

Let me show a more detailed example. You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':
enter image description here
The result:
enter image description here

Please, feel free to ask questions.

I really don't know why you don't like the answer by Rene.

Let me show a more detailed example. You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':
enter image description here
You can edit Flag labels, link type and permissions here.
The result:
enter image description here

Please, feel free to ask questions.

some screenshots added
Source Link
kalabro
  • 7.9k
  • 35
  • 46

I really don't know why you don't like the answer by Rene.

Let me show me a more detailed example. You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':
enter image description here
The result:
enter image description here

Please, feel free to ask questions.

I really don't know why you don't like the answer by Rene.

Let me show me a more detailed example.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

I really don't know why you don't like the answer by Rene.

Let me show a more detailed example. You have to replace YOURMODULE with name of your module or theme.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}

Here I'm using a flag with name 'abuse_user':
enter image description here
The result:
enter image description here

Please, feel free to ask questions.

Source Link
kalabro
  • 7.9k
  • 35
  • 46

I really don't know why you don't like the answer by Rene.

Let me show me a more detailed example.

/**
 * Implements hook_privatemsg_message_view_alter().
 * The & for param $vars is important: we pass it by reference.
 */
function YOURMODULE_privatemsg_message_view_alter(&$vars) {
  // Message author
  $uid = $vars['message']->author->uid;
  // Get flag for abusing user
  $flag = flag_get_flag('abuse_user');
  // Make flag module to check permissions
  if ($flag->access($uid)) {
    // Use flag API to show a flag according to flag preferences
    $vars['message_actions']['flag-'. $flag->name] = array(
      'title' => $flag->theme($flag->is_flagged($uid) ? 'unflag' : 'flag', $uid),
      'html' => TRUE,
    );
  }
}