Hide parts of a post

AI-generated summary

Airw0lf is looking for a way to hide parts of a post from users who do not belong to a certain group. awesomerobot suggests combining a theme component, custom CSS, and a generic BBCode wrapper to achieve this. The method involves adding a CSS class for the group, hiding the wrapped content for non-group members using custom CSS, and using a BBCode wrapper to mark the content. However, this method is not entirely secure, and savvy users may still be able to access the content. For a more secure solution, awesomerobot recommends using whisper posts for staff or developing a custom plugin.

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 (Creating a whisper post) or develop a custom plugin.