How to whitelist a list of IP addresses in Elementor Maintenance Mode

Elementor is a great plugin and Elementor Maintenance mode is a very useful tool. One thing is missing: We can’t whitelist IP addresses…


This would a really nice feature but it still doesn’t exist in 2021. You can wait for it… or just paste this short snippet in your theme’s functions.php


function my_elementor_maintenance_mode_whitelist_ips() {

	// IPs Whitelist
	$whitelist = [
		'127.0.0.1',
		'88.123.181.218',
	];

	if (
		in_array( $_SERVER[ 'REMOTE_ADDR' ], $whitelist )
		&& method_exists( '\Elementor\Plugin', 'instance' )
		&& isset( \Elementor\Plugin::instance()->maintenance_mode )
	) {
		remove_action( 'template_redirect', [ \Elementor\Plugin::instance()->maintenance_mode, 'template_redirect' ], 11 );
	}
}
add_action( 'template_redirect', 'my_elementor_maintenance_mode_whitelist_ips', 5 );
S’abonner
Notifier de
guest
0 Commentaires
Inline Feedbacks
View all comments
Défilement vers le haut