Changing comment author link
-
I have a function that makes the comment author’s name link to a profile on my site. It works great … except for the fact that it displays either Mr WordPress when the admin comments or anonymous when other users comment. I’m not sure how to change this – my php skills are rather limited – hope someone can help. One I get rid of this function, the names show properly but it will link to the comment author’s website (if they have one listed) and not their profile. I just found this function after a google search and I’ve tried messing with it but it’s not doing anything i want it to do – bad php code ??
function new_comment_author_profile_link(){ /* Get the comment author information */ global $comment; $comment_ID = $comment->user_id; $author = get_comment_author( $comment_ID ); $url = get_comment_author_url( $comment_ID ); /* Return the default WordPress comment author link if comment author is not a registered user */ if ($comment_ID == 0){ if ( empty( $url ) || 'https://' == $url ) $return = $author; else $return = "<a href='$url' rel='' class='author-url'>$author</a>"; } else { /* Return the link to the comment author's profile page if otherwise */ $return = '<a href="'.home_url().'/?author='.$comment_ID.'">'.$author.'</a>'; } return $return; } add_filter('get_comment_author_link', 'new_comment_author_profile_link');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Changing comment author link’ is closed to new replies.