WordPress Comments have wrong Comment Author IP Address when using Cloudflare Proxy

by Dec 31, 2025IT Tips0 comments

Add this to the functions.php file

function wp_use_cf_client_ip($comment_author_ip) {
    if(isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
           return $_SERVER['HTTP_CF_CONNECTING_IP'];
    }

    // return defalt otherwise
    return $comment_author_ip;
}

add_filter('pre_comment_user_ip', 'wp_use_cf_client_ip');

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.