comment_author() is utilizing the return value of get_comment_author() which invokes $author = $user->display_name; so you can change this to your appropriate database column, or better extend the function signature with an optional parameter.
Thank you to all helping contributors, I have found a solution by placing this code into the functions.php
/**
* Changes name displayed in messages/comments from Username to First Name & Last Name
*/
add_filter('get_comment_author', 'my_comment_author', 10, 1);
function my_comment_author( $author = '' ) {
// Get the comment ID from WP_Query
$comment = get_comment( $comment_ID );
if ( empty($comment->comment_author) ) {
if (!empty($comment->user_id)){
$user=get_userdata($comment->user_id);
$author=$user->first_name.' - '.substr($user->last_name,0,30).' '; // change to first name last name
} else {
$author = __('Anonymous');
}
} else {
$author = $comment->comment_author;
}
return $author;
}
One Question? In the line below, what does the 10, 1 refer to ?