• Resolved delfim

    (@delfim)


    Just entering the “comment_author_IP” function in wp-comments.php, we publish the comment author IP.
    Question:
    Is it possible to publish the comment author host name too?
    The information is available somewhere, because the email notification header mentions it loud and clear.

Viewing 5 replies - 1 through 5 (of 5 total)
  • $comment_author_domain = gethostbyaddr($comment->comment_author_IP);

    Thread Starter delfim

    (@delfim)

    Thks! ??

    Thread Starter delfim

    (@delfim)

    I’ve created 2 functions (get and echo) on comment-functions.php:

    ********
    function get_host_domain() {
    global $comment;
    $comment_author_domain = gethostbyaddr($comment->comment_author_IP);
    return apply_filters(‘get_host_domain’, $comment->comment_author_IP);
    }
    function host_domain() {
    echo get_host_domain();
    }
    *************
    but instead of the host name (IP host name, as it appears on the comment email notification

    Author : Krip (IP: 212.113.164.105 , ce01pc09.netcabo.net)

    I got only the IP number as result. Anything wrong with code?

    There is no filter get_host_domain, so that should be a no-op. For diagnostic purposes, though, remove that line. Then compare the output between
    get_host_domain();
    and
    echo host_domain();

    Do they both spit out an IP?

    Are you calling this from within the comments loop?

    Thread Starter delfim

    (@delfim)

    I’ve removed the filter

    return apply_filters(‘get_host_domain’, $comment->comment_author_IP);

    Now, neither the

    get_host_domain(); nor echo host_domain();

    show any results (no IP number too). Funny, because the function with the filter showed the IP nr., but not the IP host name.
    ******
    Yes, I’m calling this from within the comments loop:

    <h4><?php comment_type(__(‘Comment’), __(‘Trackback’), __(‘Pingback’)); ?> <?php _e(‘by’); ?> <?php comment_author_link() ?> // IP <?php host_domain(); ?></h4>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Host’s name on comments’ is closed to new replies.