¿Mostrar contenido diferente dentro de un tema según la membresía de los grupos del usuario?

Ok I realized I may need this as well so I dove more deeply into it :slight_smile:

This code doesn’t yet work and is not that pretty, but I think it’s almost good enough to go in the </head> part of the theme, just needs to have the right way to select the elements using JS:

<script type="text/discourse-plugin" version="0.8.42">

  api.decorateCookedElement(
    element => {
      var hasGroupA = document.body.classList.contains('group-a');

      const group_a_spans = element.querySelectorAll("span[data-group-a]");

      if (!group_a_spans.length) {
        return;
      }

      if (!hasGroupA) {
        group_a_spans.forEach(function (el) {
           el.innerHTML = "";
        });
      }

      },
      { id: "THEME-ID", onlyStream: true }
   );
</script>

CAVEAT: I think it may be hard to hide all the info from search and things like that, so while this may be better than just hiding it via CSS, I don’t think it’ll completely prevent people from seeing the info.

EDIT: Fixed it so the CSS selectors should work. Repeat the code for as many groups as you want to use. Change THEME-ID to a unique name. I think this should work :slight_smile:

Oops, didn’t get this part yet:

3 Me gusta