diff --git a/privatemsg.module b/privatemsg.module
index 9543ebd..28322f3 100644
--- a/privatemsg.module
+++ b/privatemsg.module
@@ -2351,14 +2351,16 @@ function privatemsg_build_modes($obj_type) {
  */
 function privatemsg_node_view($node, $view_mode) {
   $types = array_filter(variable_get('privatemsg_link_node_types', array()));
-  $url = privatemsg_get_link(user_load($node->uid));
-  if (in_array($node->type, $types) && !empty($url) && ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) && $view_mode == 'teaser'))) {
-    $node->content['links']['#links']['privatemsg_link'] = array(
-      'title' => t('Send author a message'),
-      'href' => $url . '/' . t('Message regarding @node', array('@node' => $node->title)),
-      'query' => drupal_get_destination(),
-      'attributes' => array('class' => 'privatemsg-send-link privatemsg-send-link-node'),
-    );
+  if (in_array($node->type, $types) && ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) && $view_mode == 'teaser'))) {
+    $url = privatemsg_get_link(user_load($node->uid));
+    if (!empty($url)){
+      $node->content['links']['#links']['privatemsg_link'] = array(
+        'title' => t('Send author a message'),
+        'href' => $url . '/' . t('Message regarding @node', array('@node' => $node->title)),
+        'query' => drupal_get_destination(),
+        'attributes' => array('class' => 'privatemsg-send-link privatemsg-send-link-node'),
+      );
+    }
   }
 }
 
@@ -2367,18 +2369,20 @@ function privatemsg_node_view($node, $view_mode) {
  */
 function privatemsg_comment_view($comment) {
   $types = array_filter(variable_get('privatemsg_link_node_types', array()));
-  $url = privatemsg_get_link(user_load($comment->uid));
-  if (in_array(node_load($comment->nid)->type, $types) && !empty($url) && variable_get('privatemsg_display_on_comments', 0)) {
-    $links['privatemsg_link'] = array(
-      'title' => t('Send author a message'),
-      'href' => $url . '/' . t('Message regarding @comment', array('@comment' => trim($comment->subject))),
-      'query' => drupal_get_destination(),
-    );
-    $comment->content['links']['privatemsg'] = array(
-      '#theme' => 'links',
-      '#links' => $links,
-      '#attributes' => array('class' => array('privatemsg-send-link', 'privatemsg-send-link-node', 'links', 'inline')),
-    );
+  if (in_array(node_load($comment->nid)->type, $types) && variable_get('privatemsg_display_on_comments', 0)) {
+    $url = privatemsg_get_link(user_load($comment->uid));
+    if (!empty($url)){
+      $links['privatemsg_link'] = array(
+        'title' => t('Send author a message'),
+        'href' => $url . '/' . t('Message regarding @comment', array('@comment' => trim($comment->subject))),
+        'query' => drupal_get_destination(),
+      );
+      $comment->content['links']['privatemsg'] = array(
+        '#theme' => 'links',
+        '#links' => $links,
+        '#attributes' => array('class' => array('privatemsg-send-link', 'privatemsg-send-link-node', 'links', 'inline')),
+      );
+    }
   }
 }
 /**
