Redirection to external url

Plugin Development
  • I'm using the nodebb-plugin-session-sharing plugin, so that when I'm logged in to my website I'm automatically logged in into NodeBB. In addition I don't need any other ways of loggin in. I've turned off local login, but now the login page is still there but it's empty.

    I would like to add a hook and some custom code that redirects me to the login page of my website when I click the Login button in NodeBB. What hook do I need to use? And how do I redirect to an external url?

  • You can do

    $(window).on('action:ajaxify.end', function(ev, data){
        if (data.url === 'login' && !app.user.uid) {
                window.location.href =  'http://yoursite.com/login';
        }
    });
    
  • I've placed it in the header between <script> tags and it works great. Thanks for your reply.

  • Yeah forgot to mention you can put that piece of code in your custom header at /admin/appearance/customise#custom-header


Suggested Topics