This doesn’t feel very nice since it calls get_comment() and get_userdata(), but I’m not sure there’s an obvious better way since the code that calls this doesn’t pass in the records we need:
function remove_comment_author_link( $return, $author, $comment_ID ) {
$comment = get_comment( $comment_ID );
if ( $comment && $comment->user_id ) {
$user = get_userdata( $comment->user_id );
if ( $user && $user->has_cap( "edit_posts" ) ) {
// This user is contributor or better: show author link
return $return;
}
}
// Subscriber or not a blog user
return $author;
}
and other functions have already made the exact same lookups and so the values will already be in wp_cache_get() for this page load.
I’m also using “edit_posts” to test if a user is better than subscriber: there may be better ways to do this too. (And I’m surprised we don’t have to HTML-escape $author, but the existing get_author_comment_link() code doesn’t.)