Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created August 31, 2017 11:36
Show Gist options
  • Save strangerstudios/9707b8ada410a4a70df40a612799f676 to your computer and use it in GitHub Desktop.
Save strangerstudios/9707b8ada410a4a70df40a612799f676 to your computer and use it in GitHub Desktop.
Redirect users to a maintenance.html file unless they are coming from your IP address. WordPress
/*
Lock site down to just our IP
Create a file /maintenance.html that explains that maintenance mode is on.
Update your IP address in the line below.
Add this code to your active theme's functions.php or a custom plugin.
*/
function mainenance_mode_on() {
if($_SERVER['REMOTE_ADDR'] == 'YOURIPADDRESSHERE') //find your IP and edit here
return;
wp_redirect('/maintenance.html');
exit;
}
add_action('init', 'mainenance_mode_on');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment