Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created June 30, 2020 18:46
Show Gist options
  • Save robertuniqid/71b919c493ab9e9aa2eaa5c43e067b64 to your computer and use it in GitHub Desktop.
Save robertuniqid/71b919c493ab9e9aa2eaa5c43e067b64 to your computer and use it in GitHub Desktop.
eLearnCommerce - Simple Lock WP under login.
<?php
add_action( 'init', function() {
if( is_admin() )
return;
if( is_user_logged_in() )
return;
$trimmed_url = trim( get_site_url(), '/' );
if( strpos( wpep_get_current_url(), $trimmed_url . '/wp-login.php' ) === 0 )
return;
wpep_redirect( $trimmed_url . '/wp-admin' );
exit;
}, 9999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment