Hide content from non-logged in users and redirect them to the login page.

  1. Log into your forum as an Admin

  2. Open the Admin Control Panel, you can do this via the gears icon or by appending "/admin" to your forum URL

  3. Open the "Appearance > Custom Content (HTML/JS/CSS)" page

  4. Select the Custom Javascript tab

  5. 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();
    });​
    
  6. Click the Diskette icon to the bottom right of the page to save

  7. Select the Dashboard menu

  8. Restart your NodeBB instance