Skip to content

Instantly share code, notes, and snippets.

@indikatordesign
Last active September 9, 2017 09:59
Show Gist options
  • Save indikatordesign/b7321394f171f8b07def7a9bd36698b0 to your computer and use it in GitHub Desktop.
Save indikatordesign/b7321394f171f8b07def7a9bd36698b0 to your computer and use it in GitHub Desktop.
[Divi Coming Soon Snippet]Divi allows you to create coming soon pages (blank template), but when someone tries to reach something like "my-domain.com/about/", it will achieve it because there is no implementation to hide those pages.This is what this simple snippet can do for you.
<?php
// Create a page called "Coming Soon"
// Make sure that the permalink looks like this: my-domain.com/coming-soon/
// Then paste the snippet below into your themes (child-themes) functions.php.
// After inserting, any user who is not logged-in will be redirected to your coming-soon page.
add_action( 'init', function()
{
if( ! is_user_logged_in() )
{
if ( isset( $_SERVER['REQUEST_URI'] )
&& ( '/coming-soon/' == $_SERVER['REQUEST_URI']
|| '/wp-admin/' == $_SERVER['REQUEST_URI']
|| false !== strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) ) ) return;
wp_redirect( '/coming-soon/' );
exit;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment