Skip to content
StaxWP
WordPress Plugins

How to Set Content Visibility Based on the Visitor's IP Address

By the StaxWP teamUpdated November 16, 20265 min read
How to Set Content Visibility Based on the Visitor's IP Address
Table of contents

To show or hide Elementor content by IP address, install Visibility Logic for Elementor and Visibility Logic Pro, select the element in Elementor, open the Visibility tab, switch on Enable Visibility Logic, enable the IP & Referrer condition and type the addresses in Remote IP, separated by commas. Set the action to Show to limit the element to those addresses, or to Hide to keep it from them.

The IP condition is part of Visibility Logic Pro. Below are the steps, how WordPress gets a visitor’s IP address in the first place, and why an IP rule is a display rule rather than a lock.

How does WordPress get the visitor’s IP address?

WordPress does not show visitor IP addresses anywhere by default. In PHP the address of the connection is in $_SERVER['REMOTE_ADDR']. That is the visitor’s IP on a plain server, but behind a proxy, a load balancer or a CDN it is the proxy’s address, and the visitor’s real one travels in a request header.

Visibility Logic Pro handles this in a fixed order. It uses Cloudflare’s visitor IP header when it is present. Otherwise it takes a valid IP from the client IP or X-Forwarded-For headers, and falls back to REMOTE_ADDR. On a local site that sees you as 127.0.0.1, it uses 8.8.8.8 instead, so test IP rules on the live site.

To find your own public IP address, search for “what is my IP” in any search engine, or ask your host for the address of an office network.

What do you need?

Step 1: Turn on Visibility Logic for the element

  1. Edit the page, post or template with Elementor.
  2. Select the widget, section or container.
  3. Open the Visibility tab. Older versions called it Stax Visibility.
  4. In the General section, switch Enable Visibility Logic to Yes.
  5. Set Show/Hide action. The default is Hide. To show the element only to the listed addresses, choose Show.

Step 2: Enable IP & Referrer and list the addresses

  1. Open the IP & Referrer section and switch Enable to Yes.
  2. In Remote IP, type the addresses, separated by commas, for example 203.0.113.10, 198.51.100.24.
  3. Leave Referral sites URLs or domains empty unless you also want a referrer rule.
  4. Click Update.
IP & Referrer section with two IP addresses in Remote IP, google.com and newsletter.example.com in the referrer list and Referrer Match Type Match Domain
IP & Referrer with two IP addresses and two referrer domains. Fill in only the list you need.

Each address must match exactly. The field does not take ranges, wildcards or CIDR blocks such as 203.0.113.0/24, so list every address you need. Spaces around the commas are fine.

Referrers in the same section

The same section can match where the visitor came from. Add one site per line in Referral sites URLs or domains and choose a Referrer Match Type: Match Domain, Match Exact URL or Contains.

If you fill in both lists, they are two separate checks, combined by Conditions Type in the General section. With All, a visitor must come from a listed IP and from a listed referrer. With At least one, either is enough. A visitor who types your address directly sends no referrer and never matches the referrer list. The details are in IP and Referrer.

What are IP rules good for?

Goal Action Remote IP
A staff notice that only the office network sees Show The office’s public IP
Hide a banner from your own team so it does not skew clicks Hide The office’s public IP
Show a test version of a section to a client before launch Show The client’s IP

For “everyone in a country”, use the Geo Location condition instead. Listing addresses by hand does not scale beyond a handful.

An IP rule is not access control

Two limits to be clear about.

Home and mobile addresses change. Most home connections and every mobile network hand out addresses that change over time. A rule for “my client’s IP” can stop matching the next day. Office networks with a fixed address are where IP rules work well.

Headers can be set by the client. The forwarded-IP headers that the plugin reads come from the request. Unless your proxy or host overwrites them, a visitor can send a header with any address. Use IP rules for what a page shows, not to protect anything. For private content, use a membership plugin or a login, and keep the content behind it.

What happens to hidden content?

A hidden element is left out of the page HTML. If you turn on Keep HTML/Hide by CSS, it is printed and hidden with CSS, and anyone can read it in the page source.

With Pro you can show something in its place: the Fallback section replaces the hidden element with a text or an Elementor template. See Fallback content.

Page caching matters here too. A cached page is built once and served to everyone, so the IP rule is not checked again for each visitor. Exclude pages with IP rules from the page cache (troubleshooting).

Free or Pro?

IP & Referrer is a Pro condition, like Geo Location, URL Parameters and fallback content. The free plugin includes User Role, User Meta, Date Time, Browser Type, Device Type and ACF Field. Pro costs $29 per year for 1 site, $39 for 3 sites and $79 for 100 sites, with a 30-day money-back guarantee. See the Free vs Pro table.

The short version

WordPress reads the visitor’s IP from the connection or, behind a proxy, from a header. With Visibility Logic Pro, enable IP & Referrer on an element, list the exact addresses in Remote IP, set the action to Show or Hide and test on the live site. Use it for display rules on fixed addresses, never as protection. Get Visibility Logic Pro.