Skip to content

Instantly share code, notes, and snippets.

@mspalex
Last active April 26, 2016 18:00
Show Gist options
  • Save mspalex/343e7f4206f44dd2669d8e113a5bbebc to your computer and use it in GitHub Desktop.
Save mspalex/343e7f4206f44dd2669d8e113a5bbebc to your computer and use it in GitHub Desktop.
A quick way to redirect logged off users of wordpress, when in site development. used it to redirect to a static webpage, on the same server but only a landing page for informing that is in construction
<?php
/* send logged off users to maintenance - comment to disable*/
/* sometimes reg users sessions expire, need to comment temporarily*/
function maintenance_redirect(){
if( !is_user_logged_in() ){
wp_redirect( site_url( 'em-construcao.html' ), 302 );
exit();
}
}
add_action( 'init', 'maintenance_redirect' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment