Hi Jonathan, thanks so much for sorting out how to make an author's name link to their Wordpress Users profile page. Now... do you have any idea about how to make a registered comment author's name link to their Wordpress Users profile page? :)
How to make comment author link to user profile page?
(7 posts) (2 voices)-
Posted 1 year ago #
-
Do you know how your comments.php template is structured? Does it have the old comment loop or is it using the new comment function for 2.7, wp_list_comments?
Posted 1 year ago # -
If your comments.php file uses the old comment loop, you can do it like this. Where the authors name and link is displayed in the comment output, you want to insert this code.
<?php
if ($comment->user_id) {
echo "user_id\">";
comment_author();
echo "";
} else {
comment_author_link();
}
?>You need to format the link to fit your url structure for the Users page. The user id should be inserted at the end of the url.
Posted 1 year ago # -
Ok, so it filtered out the links. Where the first echo statement is, you insert the anchor tag the same way you did for blog authors. This is how you insert the user id.
$comment->user_idWhere the second echo statement is, you close the anchor tag.
If your theme is using the new comment function instead of the old comment loop, it is much more complicated.
Posted 1 year ago # -
Here is the code again.
<?php
if ($comment->user_id) {
echo "< a href=\"?page_id=88&uid=$comment->user_id\">";
comment_author();
echo "</ a>";
} else {
comment_author_link();
}
?>To make it work, you need to remove the spaces in front of the a tags.
Posted 1 year ago # -
Thanks so much Jonathan. This is the code I used and it's working perfectly:
<?php
if ($comment->user_id) {
echo "user_id>";
comment_author();
echo "";
} else {
comment_author_link();
}
?>
Posted 1 year ago # -
Oops, links not showing, but as you might imagine, instead of "user_id>" I am using the full link with the user_id> at the end inside the quotes, and the second echo has the closing anchor tag inside the quotes. You'll see that I have not used all the '\' back-slashes. Not sure whether I was supposed to or not (I'm not a coder), but the code didn't seem to work until I stripped them out. Thanks again Jonathan, I think the ability to link authors' and comment authors' names to their profile pages really enhances your plugin.
Posted 1 year ago #
Reply
You must log in to post.