Redirect / for non-logged in users?

Hmmm, how did you do that before? I thought targetUrl was just a parameter?

Thanks a lot Robin - looks great. Only that the snippet you posted just gives me this error:

TypeError: Attempted to assign to readonly property.

or, on Chrome:

Uncaught TypeError: Cannot set property 'href' of undefined

…and makes the whole header disappear.

I guess I’m just missing something here?

Did you get the latest master first? I tried it locally and it worked fine.

That’s the first thing I did before trying it! Is there a special section where I have to put the script code?

Aha it seems the tests-passed branch failed to build due to a failing test. I’m fixing it now.

edit: fixed the test. Give it 15-20 mins and it should have a new version for you.


Sorry, this was done in a hurry :laughing:

  window.goToPortal = function() { 
      if (window.location.href === '') { 
          window.location = '';

  var HeaderView = require('discourse/views/header').default

    didInsertElement : function(){
      this._super();'afterRender', this, this.afterRenderEvent);
    afterRenderEvent : function(){
      var logo = $('img#site-logo.logo-big').parent()[0];
      logo.addEventListener('click', window.goToPortal, false);

Can you help me @eviltrout ?

Like a charm. Thanks!

Hmmm that is a little complicated to establish in the new settings. Does adding that event work in the case where the url is not ? It seems the click handler would do nothing.

Yes, when the user isn’t at the forum home, I want the normal behavior (scroll up / go back to home).

Only when we are already at the forum home, I want to go back to my Portal home.

It’s quite tricky to do what you’re asking, because once an event is handled from the logo it prevents default.

I’ve added the ability for the href setting to be a function. Whatever value you return will be the destination when the user clicks the logo:


Should this work?

<script type="text/discourse-plugin" version="0.4">
  api.changeWidgetSetting('home-logo', 'href', function() { 
          return '';


Setting it to ‘/another/page’ when using Discourse under ‘/forum’ also breaks :sadpanda:.

1 Like

This should fix it:


I’ll test this later today! Thanks! :heart:

1 Like