20 Feb 2009

Remove or Unlink WordPress Comment Author URL

This code will remove or unlink comment author URL from the comment list if the comment author that left any comment is not registered or logged in (except for trackback and pingback). The original comment author URL in the database remains untouched.

Add the following lines to your WordPress Theme’s template functions.php file (For example, functions.php file for a Theme named “default” would probably reside in the directory wp-content/themes/default/functions.php) or create it as a Plugin by filling the additional Standard Plugin Information:

<?php
function unlink_comment_author_link($output) {
	global $comment;

	$author = get_comment_author();

	if ((get_comment_type() == 'comment')) {
		if ($comment->user_id > 0 && $user = get_userdata($comment->user_id))
			return $output;
		else
			return $author;
	} else {
		return $output;
	}
}

add_filter('get_comment_author_link', 'unlink_comment_author_link');
?>