Restrict roles to IP addresses
This feature lets you say: “people with this role can only sign in from these IP addresses.” It’s an allow list per role. For example, you can make administrators sign in only from your office or home network, while customers and subscribers can still sign in from anywhere.
It’s one of the strongest settings Shield has, because a stolen password is useless from the wrong network. It’s also the easiest to lock yourself out with, so read the warnings below before you use it.

Where to find it#
Go to Settings → Login Shield → Access tab. The section is called Restrict roles to IP addresses and sits under the XML-RPC section. It lists every role on your site, each with its own box.
How it works#
- A role with an empty box is unrestricted. Nothing changes for those users. This is the default for every role.
- A role with addresses in its box is restricted. Users in that role can only sign in from one of those addresses.
- A user with more than one role: if any of their restricted roles allows the address, they’re allowed in. If a user has one restricted role and one unrestricted role, only the restricted role counts. For example, someone who is both an Editor and a Shop Manager can sign in from an address that is on either role’s list.
- Users with no restricted role are never affected.
What to put in the boxes
Enter one IP address or range per line. Supported formats:
- A single IPv4 address, like
203.0.113.10 - A single IPv6 address, like
2001:db8::25 - A range in CIDR format, like
198.51.100.0/24(IPv4) or2001:db8::/32(IPv6)
Entries that aren’t valid are dropped when you save.
Set it up#
- Find your current IP address. The section shows it in a yellow box: “Your current IP is …”. Write it down.
- In the box for the role you want to restrict (for example Administrator), enter your IP address and any others that should be allowed, such as your office, home, VPN or a colleague’s.
- Click Save access settings.
- Without closing your current session, open a private browser window and test a login from an allowed network. Then, if you can, test from a network that isn’t on the list. For example, use your phone on mobile data. The second test should be refused.

A built-in safety net
If you save a rule that would block your own IP, Shield refuses to save it and shows: “Not saved: the rule for role “[role]” would block your own current IP ([your IP]). Add it to the list first.” This protects you from the most common mistake. It only checks your current address, though, not other people’s.
What it covers#
When a user is in a restricted role and signs in from an address that isn’t allowed, they see “Access denied.” On a login form it appears as a login error; for magic links, passkeys and REST requests it is a 403 response. That applies to:
- the normal login page,
- WooCommerce My Account login,
- magic links and passkeys,
- REST API requests,
- XML-RPC logins.
The password is checked first. Shield only refuses a user whose password was correct, so an attacker guessing passwords can’t use this feature to find out which accounts exist.
Each refusal is written to the event log as ip_restricted, with the role. It also counts as a failed login toward lockouts, so repeated tries from the wrong address can lock that address out. See “The event log”.
Important: it does not use your whitelist#
Unlike most Shield features, this one ignores the Whitelisted IPs list on the Lockout tab. It also ignores the NAHNLS_BYPASS_IP setting. An address has to be in the role’s own box. This is on purpose: an allow list is meant to bind everyone, including administrators.
That means the emergency bypass in wp-config.php will not get you back in if a role’s list is wrong. See “Getting back in” below.
Things to be careful about#
- Your IP must be the real visitor IP. Behind a CDN or proxy, Shield may see the proxy’s address unless Trust proxy headers is on (Lockout tab). With it wrong, every administrator could be refused. See “Lockouts are keyed to the wrong IP (proxies and CDNs)”.
- Home and mobile addresses change. Most home internet connections and all mobile connections get a new address from time to time. A list with a single home address will lock you out eventually. Use a CIDR range for your provider only if you understand what it covers, or sign in through a VPN or office connection with a fixed address.
- Don’t restrict a role to a single address if you can’t recover. Always have a second way in, such as another administrator account on a second allowed address, or FTP/hosting access.
- People already signed in aren’t signed out. The rule is checked when someone signs in and when they make REST requests. Someone who already has a session cookie from a disallowed address can keep browsing the admin pages until the session ends. To end sessions now, use the Force logout option described in “Session security”.
- Roles with many members. Test with an ordinary user of the role, not only your own account.
Getting back in#
If a bad rule locks you out:
- Use FTP, your hosting file manager or WP-CLI to clear the rules. See “I locked myself out” in the Troubleshooting section for the exact steps.
- Or, if you have another administrator who is allowed in, ask them to fix the list.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!