WordPress.org

Support

Support » How-To and Troubleshooting » Admins can see comenter hostname, but I need to defer processing for performance

Admins can see comenter hostname, but I need to defer processing for performance

  • 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!

  • The topic ‘Admins can see comenter hostname, but I need to defer processing for performance’ is closed to new replies.
Skip to toolbar