Hide parts of a post

See also this post:
We have some text included in the following html tags.

<details>
  <summary>Antwoord</summary>

	Some tekst or code

</details>

Is there a way to hide this part for users who do not belong to a certain group?
Any other suggestion on making this happen?

Cheers

You can combine a few things to achieve this.

  1. this theme component: CSS Classes for Current User's Groups

  2. a little bit of custom CSS in your theme

  3. this feature: Generic bbcode wrapper for theme components

So for example, if you have a group named foo, the theme component (1) will add .group-foo to the page for all members of the group.

Then add this custom CSS (2) to your theme:

body:not(.group-foo) {
  [data-wrap="group-foo-only"] {
    display: none;
  }
}

Now you can use a generic bbcode wrapper (3) in a post’s content like this…

[wrap="group-foo-only"]
Only members of the group foo will see this content
[/wrap]

So the CSS will hide the wrapped content for anyone that’s not a member of the foo group.

Note that this isn’t an entirely secure method to do this, savvy users could use their browser tools or safe mode to see this content if they knew what to look for.

If you need a secure method to hide content, you’d need to utilize a feature like whisper posts for staff (Create a Whisper post) or develop a custom plugin.

9 Likes