Disable “?u=<user>” in shared links


(Esko) #1

When you copy a link via the Share button Discourse appends “?u=jooize” (in my case). I want to disable this, can I do that without modifying the source code?


(Régis Hanol) #2

What’s bothering you with that query string?


(Esko) #3

Our community is privacy conscious and when you might want to link something under a different identity you don’t want to accidentally include your username.


(Jeff Atwood) #4

It would also make certain badges impossible to achieve, though. I understand the concern, I guess…


(mountain) #5

Which badges? The Shares? Well…if the community is private I kind of see Sharing a moot point. From my POV as a private-community owner, I honestly wouldn’t want sharing in the first place, except to allow users to link within the community itself for the purpose of writing replies.

Don’t know if it’s an option to turn all that off and disable/remove default badges like Shares.


(Wes Osborn) #6

Yes, this can be done in /admin/badges. Select the badge for example Nice Share then scroll down to the bottom and uncheck the the Enable Badge checkmark box.

If you go under /admin and type share into the the filter box, then you’ll should be able to remove the share option from the post menu.


(Sam Saffron) #7

This is not configurable now, you would need a source level modification to disable it. Open to adding a site setting if you wish.


(Esko) #8

We would really appreciate that, @sam.


(Sam Saffron) #9

Sure, but someone is going to have to contribute this.


(system) #10

(Sam Saffron) #11

This can now be done in a theme component, @Johani if you can swing this in 15 minutes can you demo how it would be done.


(Joe) #12

This should do it

<script type="text/discourse-plugin" version="0.8">
const sharePopup = require("discourse/components/share-popup").default;
sharePopup.reopen({
  _focusUrl() {
    const link = this.get("link").split("?");
    if (!this.capabilities.touch) {
      const $linkInput = $("#share-link input");
      $linkInput.val(link[0]);
      window.setTimeout(() => $linkInput.select().focus(), 160);
    } else {
      const $linkForTouch = $("#share-link .share-for-touch a");
      $linkForTouch.attr("href", link[0]);
      $linkForTouch.text(link[0]);
      const range = window.document.createRange();
      range.selectNode($linkForTouch[0]);
      window.getSelection().addRange(range);
    }
  }
});
</script>

Here’s a preview on theme creator


(system) #13

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.