Force User Login
Hide content from non-logged in users and redirect them to the login page.
- Log into your forum as an Admin
- Open the Admin Control Panel, you can do this via the gears icon or by appending "/admin" to your forum URL
- Open the "Appearance > Custom Content (HTML/JS/CSS)" page
- Select the Custom Javascript tab
- Paste in the following code:
$(document).ready(function () {
function redirectAnon () {
if (!app.user.uid && document.location.pathname !== '/login') {
document.location = config.relative_path + '/login';
}
}
$(window).on('action:ajaxify.end', redirectAnon);
redirectAnon();
});
- Click the Diskette icon to the bottom right of the page to save
- Select the Dashboard menu
- Restart your NodeBB instance