Function Maintenance Mode
  • LET'S TALK!

    Fill in the form below to make an enquiry or find my contact details on my contact page.

  • This field is for validation purposes and should be left unchanged.

Freelance WordPress Developer

Function Maintenance Mode

If you need a quick and easy way of locking your site to non-admin users, just use this code snippet:


/**
 *
 * Function Maintenance Mode
 */
if ( ! function_exists( 'ns_maintenace_mode' ) ) {
function ns_maintenace_mode() {
 if ( ! current_user_can( 'edit_themes' ) || ! is_user_logged_in() ) {
   die( 'YOUR MESSAGE' );
 }
}
add_action( 'get_header', 'ns_maintenace_mode' );
}

This will present a blank page with your chosen message.

ABOUT AUTHOR

Nuno

Hi, I'm a Freelance Web Developer and WordPress Expert based in London with a wealth of website development and support experience. I am great at problem solving and developing quick solutions.