I put my site in maintenance mode using this hook in functions.php,

function activate_maintenance_mode() {
    //If the current user is NOT an 'Administrator' or NOT 'Super Admin' then display Maintenance Page.
    if ( !(current_user_can( 'administrator' ) ||  current_user_can( 'super admin' ))) {
        //Kill WordPress execution and display HTML maintenance message. 
        wp_die('<h1>Sitio en mantenimiento</h1><p>Nuestro sitio esta actualemente en mantenimiento. 
            <br /><strong>Ya volvemos!</strong></p>', 'mantenimiento');
//Hooks the 'activate_maintenance_mode' function on to the 'get_header' action.
add_action('get_header', 'activate_maintenance_mode');

and now I can't return back to normal mode.

EDIT: The problem had to be with W3 Total Cache plugin.

  • Did you add it to your functions.php file via your Dahsboard > Appearance > Editor or did you do this via an external text editor and FTP?
    – Matt Royal
    Commented Jun 30, 2014 at 7:09
  • External editor + FTP Commented Jun 30, 2014 at 7:18
  • 1
    Just remove that code and you should be fine. BTW: not sure if current_user_can( 'super admin' ) part with the space will work. You can try with any super admin caps like current_user_can( 'manage_network' )
    – Sisir
    Commented Jun 30, 2014 at 7:18
  • I've commented it out I forgot to say! Commented Jun 30, 2014 at 7:21
  • 1
    Clear you browser cache. Commented Jun 30, 2014 at 7:23

2 Answers 2


Since you are using the W3 total cache plugin, So The HTML code will be cached in the wp-content/cache folder. So Delete Cache folder from wp-content directory.

Now remove the function activate_maintenance_mode() and check the site now...

If the problem exists , Delete the W3 total Cache Constant from wp-config.php and clear your browser data and check the site.


I think the code is wrong, you are basically using WP_die for super admins when you say :

if ( !(current_user_can( 'administrator' ) ||  current_user_can( 'super admin' )))

I think the correct code should be

if ( !(current_user_can( 'administrator' ) &&  !(current_user_can( 'super admin' ))))

Can you try this and let me know. Praveen

  • ok, i've changed it. However I keep stucked, so I cannot see if it works. Commented Jun 30, 2014 at 7:26
  • Can you then alter it so that it is only if ( !(current_user_can( 'administrator' )) { wp_die();}
    – Praveen
    Commented Jun 30, 2014 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.