How to add link to Comment Author's User Profile page The below code is from the comment.tpl.php file:

&lt;div class="comment-avartar"&gt;
&lt;?php print $picture ?&gt;
&lt;div class="submitted"&gt;&lt;?php print render($content['submitted_by'] ['#markup']);?&gt;&lt;/a&gt;&lt;/div&gt;




I want "$content['submitted_by'] ['#markup']" to link to the user profile of the user who posted the comment.

i have tried editing the code to something like this:

&lt;?php $link = drupal_get_path_alias('user/' . $user-&gt;uid);?&gt;

&lt;div class="comment-avartar"&gt;
&lt;?php print $picture ?&gt;
&lt;div class="submitted"&gt;&lt;a href="&lt;?php $link ;?&gt;"&gt;&lt;?php print render($content['submitted_by'] ['#markup']);?&gt;&lt;/a&gt;&lt;/div&gt;




But it links to the user profile of the currently logged in user.

What I would like is to link it to the profile of the Comment author.

Thank you.
Comment module does add a link to comment author name on comments view. The link is conditionally visible to user's i.e. If user has permission to "View user profiles" or administrative permission then he will be able to see author name as link, else plain text. See screenshots below (tested with Anonymous user with and without permission "View User Profiles"):

Permissions:


Comment preview with permission:



Comment preview without permission:



You can still add a link to author name by your own, by implementing template_preprocess_comment() function in your theme's template.php or .module file. This might lead to access denied page:

/**
 * Process variables for comment.tpl.php.
 *
 * @see comment.tpl.php
 */
function [THEME_NAME]_preprocess_comment(&amp;$variables) {
  if (!empty($variables['elements']['#comment']-&gt;uid)) {
    $variables['comment_author'] = l($variables['elements']['#comment']-&gt;name, 'user/1/' . $variables['elements']['#comment']-&gt;uid);
  }
  else {
    $variables['comment_author'] = t('Anonymous');
  }
}


And then printing "$comment_author" variable in comment.tpl.php file, see below.

&lt;p class="commenter-name"&gt;
  &lt;?php print $comment_author; ?&gt;
&lt;/p&gt;