Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
Easily hide your WordPress site from public viewing by requiring visitors to log in first. As simple as flipping a switch.
Make your website private until it’s ready to share publicly, or keep it private for members only.
Features
Bug Reports
Bug reports for Force Login are welcomed on GitHub. Please note that GitHub is not a support forum.
Upload the Force Login plugin to your site, then Activate it.
1, 2: You’re done!
By default, the plugin sends visitors back to the URL they tried to access. However, you can redirect users to a specific URL by adding the built-in WordPress filter login_redirect to your functions.php file.
You can bypass Force Login based on any condition by adding the following filter to your functions.php file.
You may use the WordPress Conditional Tags in your code.
/** * Bypass Force Login to allow for exceptions. * * @param bool $bypass Whether to disable Force Login. Default false. * @param string $visited_url The visited URL. * @return bool */ function my_forcelogin_bypass( $bypass, $visited_url ) { // Allow 'My Page' to be publicly accessible if ( is_page('my-page') ) { $bypass = true; } return $bypass; } add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 2 );
Check out the Force Login Wiki on GitHub for additional examples to allow URLs to be publicly accessible.
The WordPress login screen includes a “
Back to {sitename}” link below the login form; which may not actually take you back to the site while Force Login is activated. You can hide this link by adding the following action to your functions.php file.Requires: WordPress 2.5 or higher
// Hide the 'Back to {sitename}' link on the login screen. function my_forcelogin_hide_backtoblog() { echo '<style type="text/css">#backtoblog{display:none;}</style>'; } add_action( 'login_enqueue_scripts', 'my_forcelogin_hide_backtoblog' );