WordPress.org

Ready to get started?Download WordPress

Forums

Admins can see comenter hostname, but I need to defer processing for performance (1 post)

  1. haniobaid
    Member
    Posted 5 years ago #

    I have working code below to allow only the admin to see each commenter's IP and also to resolve it to that IP's hostname. What I'd like ideally is to have it load the page first and defer the statement which resolves the IP to a hostname afterwards, because the current implementation causes a 30 post comment to take up to 2 minutes to open for the admin user (which is the problem) and a few seconds for none-admin users (which is perfect).

    I appreciate any assistance in this matter

    <?php global $user_ID; if( $user_ID ) : ?><?php if( current_user_can('level_10') ) : ?> <?php echo " from " . $comment->comment_author_IP . " " . gethostbyaddr($comment->comment_author_IP); ?><?php endif; ?><?php endif; ?>

    Secondary objective:
    If possible not to display the resolved hostname if it's the same as the ip address (i.e. if it doesn't resolve). I had setup an if statement to compare the two but it never works and ends up displaying the whole if statement on the comment instead!

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 5 years ago by haniobaid
  • This topic is not a support question
  • WordPress version: 2.6.1