WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Host's name on comments (6 posts)

  1. delfim
    Member
    Posted 9 years ago #

    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.

  2. skippy
    Member
    Posted 9 years ago #

    $comment_author_domain = gethostbyaddr($comment->comment_author_IP);

  3. delfim
    Member
    Posted 9 years ago #

    Thks! :)

  4. delfim
    Member
    Posted 9 years ago #

    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?

  5. skippy
    Member
    Posted 9 years ago #

    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?

  6. delfim
    Member
    Posted 9 years ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags