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

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?

3 Likes

What’s bothering you with that query string?

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.

2 Likes

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

1 Like

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.

2 Likes

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.

2 Likes

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

We would really appreciate that, @sam.

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

3 Likes

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.

4 Likes

This should do it

<script type="text/discourse-plugin" version="0.8">
  const later = require("@ember/runloop").later;

  api.modifyClass("component:share-popup", {
    _focusUrl() {
      this._super(...arguments);

      // Needs later because of https://git.io/JfmTU
      later(() => {
        if (this.element) {
          const linkInput = this.element.querySelector("#share-link input");
          linkInput.value = this.link.split("?")[0];
        }
      }, 200);
    }
  });
</script>
8 Likes

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