• Resolved aaronjpitts

    (@aaronjpitts)


    Is there a way to disable only the wp-admin section when in maintenance mode but keep the front-end fully available to all users? For example I want to use the plugin to make sure none of my editors can make any changes to any posts whilst I’m doing maintenance, as I use WP Migrate DB Pro to sync databases and don’t want them to lose any work whilst I do that, but I would like the front-end still accessible at this time.

    I know you can add roles to allow to view the front-end in maintenance mode, this would be sufficient enough if you could allow guests also to still view the front-end in maintenance mode. Is that possible?

    Many thanks for a great plugin 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @aaronjpitts,

    There is no setting to achieve what you want, but you can use the built-in hooks.

    Place the next snippet of code at the end of the functions.php file (located inside your active theme/child-theme directory).

    
    /**
     * Disable maintenance mode on frontend
     * 
     * @param boolean $is_excluded
     * @return boolean
     */
    function wpmm_disable_maintenance_mode_on_frontend($is_excluded) {
    	if (!is_admin()) {
    		$is_excluded = true;
    	}
    
    	return $is_excluded;
    }
    
    add_filter('wpmm_is_excluded', 'wpmm_disable_maintenance_mode_on_frontend', 11, 1);
    

    This way is not necessary to set any backend/frontend roles.

    Later edit: snippet updated


    George

    • This reply was modified 5 years, 1 month ago by George J.
    • This reply was modified 5 years, 1 month ago by George J.
    Thread Starter aaronjpitts

    (@aaronjpitts)

    Works perfectly now.

    Thank you very much, George!

    Thread Starter aaronjpitts

    (@aaronjpitts)

    Just one scenario I could see being a problem and maybe just a future suggestion.

    If one of my editors is editing a post and they are on the edit post screen, say I then at the same time activate the maintenance mode before they hit the publish/update button, it will cause them to lose their work. Is it possible to allow any possible saving to a post before effectively kicking them out?

    Many thanks

    @aaronjpitts: I don’t have a workaround for this scenario. But I think the autosave feature present in WordPress should be enough.

    If you want to change the autosave interval, here’s how you can do it: https://codex.wordpress.org/Editing_wp-config.php#Modify_AutoSave_Interval

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to block wp-admin only?’ is closed to new replies.