Hide content in templates with Groups

Posted in

We have a do_action() part of our theme and want to restrict it to users of two specific groups only. How do we put that do_action() in between the shortcode in the template file?

We’ve looked at the API page and the do_shortcode but can’t figure out exactly how to do it.

Any help is appreciated, thank you.

8 Responses to Hide content in templates with Groups

  1. Eugen Bleck May 11, 2020 at 3:55 pm #

    Hi Thomas,

    I trust you had a wonderful weekend and are doing great!

    Please can you provide the code they are using? You could use pastebin and share the link in the comment.

    Warm regards,
    Eugen.

    • Thomas Trudeau May 12, 2020 at 2:57 am #

      All I want to do is restrict this line of code to two specific Groups, which produces an info box on our theme: https://pastebin.com/kJs9Wku8

      Thanks for the help.

      • Eugen Bleck May 12, 2020 at 6:04 pm #

        Hi Thomas,

        Thanks for the prompt response.

        However, I don’t think you can restrict a hook, as long as it is implemented everyone can use it.

        I’ll suggest you consider the shortcode approach to solving this issue. Implement a shortcode, wherein the shortcode callback function can do the group check and display company_box.

        Link to shortcodes codex: https://developer.wordpress.org/reference/functions/add_shortcode/

        Stay safe!
        Warm regards,
        Eugen.

  2. Thomas Trudeau May 9, 2020 at 4:09 am #

    Hi there, yes I looked at this and we tried a few different things using that but couldn’t get it to work. In the theme we are using, we have this line of code that displays some information:

    We want to restrict this to logged-in users of two specific groups only using this shortcode somehow:
    [groups_member group="Advanced,Premium"][/groups_member]

    We tried to use some of the API info but our knowledge of it wasn’t good enough to get it working.

    Any further help much appreciated.

    • Thomas Trudeau May 9, 2020 at 4:31 am #

      Oops, realized the line of code didn’t get shown, this is the line of code we want to restrict:

      “”

      We looked at this “Does the current user belong to the Foobar group?” but couldnt figure out how to complete it with the shortcode parameters.

      Thank you

      • Thomas Trudeau May 9, 2020 at 4:34 am #

        Last try:
        “”

        Ignore the weird markup, just want to show it.

        • Thomas Trudeau May 9, 2020 at 4:36 am #

          Had to use screenshot, not sure how to paste code in here: https://ibb.co/0XXgTP7

  3. Eugen Bleck May 8, 2020 at 2:51 pm #

    Hi Thomas,

    I trust you are safe and feeling awesome.

    Thanks for using Groups and its extension; Groups Restrict Categories.

    To best help you, I’ll need more information with regard to the tasks you are trying to accomplish.

    I’ll recommend you have a look at the example: Does the current user belong to the Foobar group? here: http://docs.itthinx.com/document/groups/api/examples/.

    Once more, thank you for reaching out and for using Groups Restrict Categories.

    Stay safe and I wish you a lovely weekend ahead.

    Kindest regards,
    Eugen.

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share