Linking comments from registered users to their profile pages

I have written a solution for that some time ago:

<?php # -*- coding: utf-8 -*-
/**
 * Plugin Name: T5 Comment author URI to blog author page
 * Description: Changes the comment author URI to the blog’s author archive
 * Version:     2012.07.18
 * Author:      Fuxia Scholz
 * Author URI:  https://fuxia.me
 * License:     MIT
 * License URI: http://www.opensource.org/licenses/mit-license.php
 */

if ( ! function_exists( 't5_comment_uri_to_author_archive' ) )
{
    add_filter( 'get_comment_author_url', 't5_comment_uri_to_author_archive' );

    function t5_comment_uri_to_author_archive( $uri )
    {
        global $comment;

        // We do not get the real comment with this filter.
        if ( empty ( $comment )
            or ! is_object( $comment )
            or empty ( $comment->comment_author_email )
            or ! $user = get_user_by( 'email', $comment->comment_author_email )
        )
        {
            return $uri;
        }

        return get_author_posts_url( $user->ID );
    }
}

Leave a Comment