WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I strongly need to edit some parts of the comments left by the users, I want to add a link to the commenter's author.php page if he/she is a registered user by placing a text link somewhere next to his/her name. I've this code <?php wp_list_comments(); ?> but I wonder if it's possible to have the full code instead to replace it in comments.php Thanks!

share|improve this question
up vote 1 down vote accepted

This function replaces the comment author's link with the comment author's profile page, if the comment author is a registered user. Otherwise, the standard WordPress comment author link is displayed.

This function is not mine and has been found googling.

function graphene_comment_author_profile_link(){
    /* Get the comment author information */
    global $comment;
    $comment_ID = $comment->user_id;
    $author = get_comment_author( $comment_ID );
    $url    = get_comment_author_url( $comment_ID );

    /* Return the default WordPress comment author link if comment author is not
    a registered user */
    if ($comment_ID == 0){
        if ( empty( $url ) || 'http://' == $url )
            $return = $author;
            $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
    } else {
    /* Return the link to the comment author's profile age if otherwise */
        $return = '<a href="'.home_url().'/?author='.$comment_ID.'">'.$author.'</a>';

    return $return;
add_filter('get_comment_author_link', 'graphene_comment_author_profile_link');
share|improve this answer

the function wp_list_comments() has a 'callback' parameter; using a callback function should allow you to edit the code as you described.

for example see in the default theme Twenty Eleven how it is used;

in comments.php:

        wp_list_comments( array( 'callback' => 'twentyeleven_comment' ) );

the actual functions code is in functions.php, starting with:

function twentyeleven_comment( $comment, $args, $depth ) {
share|improve this answer
Thanks Michael but I found a function that makes the name of the registered user linking to his/her profile without modifying anything else. – user27309 Mar 20 '13 at 16:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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