Link to send private message to current user in the node (author of the content)? Is it possible to create a link to send private message to CURRENT USER in the node (to the author of the node content to be more precise). I'm using the Privatemsg module.
I was trying to do this with the Display suite dynamic fields, but I am not able. 

I found that the Privatemsg module comes with an option to "Display link on the selected content types. So, I have the "contact current member link" right in the content type, but it shows only for logged in users.

Is there any configuration or hook that I can implement to show the same link to anonymous user?

This is the code that shows the link.

function privatemsg_node_view($node, $view_mode) {
  $types = array_filter(variable_get('privatemsg_link_node_types', array()));
  $url = privatemsg_get_link(user_load($node-&gt;uid));
  if (in_array($node-&gt;type, $types) &amp;&amp; !empty($url) &amp;&amp; ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) &amp;&amp; $view_mode == 'teaser'))) {
    $node-&gt;content['links']['#links']['privatemsg_link'] = array(
      'title' =&gt; t('Contact member'),
      'href' =&gt; $url . '/' . t('Message regarding @node', array('@node' =&gt; $node-&gt;title)),
      'query' =&gt; drupal_get_destination(),
      'attributes' =&gt; array('class' =&gt; 'button radius privatemsg-send-link privatemsg-send-link-node'),
    );
  }
} 


To make it clearer, I don't want anonymous user to send messages. What I want is just a link to log in for anonymous users. Expressing it with pseudo-code...

global $user;

if (isset($user-&gt;roles[1])) {
  // Do not show button to Anonymous user and show something else or a button to log in (THE CODE FOR LOG IN)
  echo "something else";
}
else {
  // Show button to logged in user (the code of "Send author a message" button)
}
I did it with a Display suite custom code field. With it I am able to use some PHP code.

global $user;
// If the user is anonymous (role=1) show this; otherwise show nothing.
if (isset($user-&gt;roles[1])) {
  print l(t('Contact member'), 'user/login', array('attributes' =&gt; array('class' =&gt; array('radius', 'button'))));
}


So, when the user is logged-in, this code above will be replaced with the contact member link (Send author a message).