To whitelist IP addresses in WordPress, you can use a security plugin like Wordfence or a custom code in your theme’s functions.php file.
Using Wordfence:
- Install and activate the Wordfence plugin.
- Go to the Wordfence menu in the WordPress dashboard and click on the “Firewall” tab.
- Scroll down to the “Whitelisted IP addresses” section and click “Add IP” to add the IP addresses you want to whitelist.
Using custom code:
- Connect to your WordPress site using FTP or File Manager in cPanel.
- Open the functions.php file of your theme in a code editor.
- Add the following code at the end of the file, replacing the example IP addresses with the ones you want to whitelist:
function whitelist_ip_addresses() {
if (in_array($_SERVER['REMOTE_ADDR'], array('IP_address_1', 'IP_address_2'))) {
return true;
}
}
add_filter('pre_option_require_name_email', 'whitelist_ip_addresses');
- Save the file and upload it to your server.
With either method, the specified IP addresses will be allowed to access your site and bypass any security measures in place, so use caution when whitelisting IPs.