NodeBB Answers

    • Login
    • Search

    Force User Login

    Admin Control Panel
    1
    1
    2275
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      NodeBB last edited by

      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
      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Powered by NodeBB | Contributors