Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
T5 Comment author URI to author archive
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Comment author URI to author archive
* Description: Changes the comment author URI to the blog’s author archive
* Plugin URI: http://toscho.de/?p=1900
* Version: 2012.07.18
* Author: Thomas Scholz
* Author URI: http://toscho.de
* 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' );
/**
* Change $uri to author archive URI if possible.
*
* @wp-hook get_comment_author_url
* @param string $uri
* @return string
*/
function t5_comment_uri_to_author_archive( $uri )
{
global $comment;
// We do not get the comment as argument with this filter.
// So we have to poke around …
if ( empty ( $comment )
or ! is_object( $comment )
or empty ( $comment->comment_author_email )
or ! $user = get_user_by( 'email', $comment->comment_author_email )
)
{
// Nothing to do.
return $uri;
}
return get_author_posts_url( $user->ID );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.