Must Login is a lightweight, user-friendly plugin that allows you to require login for your entire site with just one click. Perfect for membership sites, private blogs, intranets, or any site that needs to restrict access to registered users only.
When enabled, all visitors must log in to view any page on your site. Administrators can quickly toggle this on or off from anywhere on the site using the admin bar.
cfb_must_login_redirect_url – Customize the login redirect URL
add_filter('cfb_must_login_redirect_url', function($redirect_url, $redirect_to) {
return 'https://example.com/custom-login';
}, 10, 2);
cfb_must_login_allowed_rest_routes – Allow additional REST API endpoints
add_filter('cfb_must_login_allowed_rest_routes', function($routes) {
$routes[] = '/my-plugin/v1/public';
return $routes;
});
cfb_must_login_clear_cache – Triggered when cache is cleared
add_action('cfb_must_login_clear_cache', function() {
// Custom cache clearing logic
});
The plugin uses the cfb_must_login_manage capability, which is mapped to manage_options by default. You can customize this using the map_meta_cap filter.