sandywp / plugins / wp-force-login
Force Login
Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
Ready in seconds.
v5.6.3 30,000+ installs WP 4.6+

About this plugin
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
- WordPress Multisite compatible.
- Login redirects visitors back to the url they tried to visit.
- Extensive Developer API (hooks & filters).
- Customizable. Set a specific URL to always redirect to on login.
- Filter exceptions for certain pages or posts.
- Restrict REST API to authenticated users.
- Translation Ready & WPML certified.
Bug Reports
Bug reports for Force Login are welcomed on GitHub. Please note that GitHub is not a support forum.
Questions
- 1. How can I specify a redirect URL on login?
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.
- 2. How can I add exceptions for certain pages or posts?
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.
- 3. How do I hide the “← Back to {sitename}” link?
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' );
sandywp / also on the shelf
Try another plugin
Cookie Compliance for WordPress – Cookie Consent, GDPR & CCPA
4.8 · 900K+ installs
Consent management platform for WordPress — GDPR, CCPA & ePrivacy cookie consent, autoblocking, consent records, Google…
5.0 · 200K+ installs
Simple Consent API to read and register the current consent category.
Gravatar Enhanced – Avatars, Profiles, and Privacy
5.0 · 100K+ installs
The official Gravatar plugin, featuring privacy-focused settings, easy profile updates, and customizable Gravatar Profile blocks.
Spin up a real WordPress site in seconds.
Test plugins, build a demo, hand a client a link — then squash it and start again. No local setup, no Docker.