tags:

views:

35

answers:

2

Hello,

At the wordpress form, when you leave comment as guest, there's a website field to fill your web address. If we fill in that box, we can get the link by calling this function

<?php echo get_comment_author_link(); ?>

But if you are logged in and you don't add the website at your profile, when you leave comment. It doesn't have the link on your username.

What I want is, if the logged-in user doesn't have the website, there will be the link which will be carry them to their profile page which is something like http://www.example.com?author=21

Is there any function that i can use out there ? Please help me out. Thank you.

A: 

well i guess a workaround is to have a php/mySQL script update the empty database fields in wordpress database to the value you want

mireille raad
A: 

Drop this in your theme's functions.php;

function force_comment_author_url($comment)
{
    // does the comment have a valid author URL?
    $no_url = !$comment->comment_author_url || $comment->comment_author_url == 'http://';

    if ($comment->user_id && $no_url) {
        // comment was written by a registered user but with no author URL
        $comment->comment_author_url = 'http://www.example.com/?author=' . $comment->user_id;
    }
    return $comment;
}
add_filter('get_comment', 'force_comment_author_url');
TheDeadMedic
thanks works like a charm. I really want to give you vote for that. Currently I don't have enough rep to vote. Thank you so much again.
knightrider
No problem, glad to help :)
TheDeadMedic