Groups Hook for Shortcodes

Posted in

Posting this again, as responses to the original are locked out so i cannot reply to the support response.

—Original Request—
Is there a way to hook into the existing groups shortcode and edit how the “locked content” description looks?

I know that there is a template modification example with the 2020 template to show only an excerpt, but on the site we are using the plugin we want the author to be able to use the shortcode around whatever content they want and that locked content would then show an image with a “click here to subscribe”. All i can find is a login option or a standard button that says click to subscribe or login.

We want to do a little bit more robust option for the “content lock”

Basically a way to hook into the shortcode and have html code show when the content is locked, different for each shortcode or universal for all shortcodes.

—Updated Reply —

An example of this usage is that we have a site and we use some of the shortcodes to block content on blog posts and some custom post types, and we have edited the plugin itself to customize how the “paywall” looks.

The shortcode we use is: [groups_member group=”premium”] where “premium” is a group that has access to the blocked content. When a user that isn’t a premium member is on the site, they will see some text and an image that links the user to a signup page. We are currently achieving this by editing the shortcode directly in the plugin, so we are unable to update to the latest plugin currently.

our goal is to be able to customize the look of the “blocked content/paywall” that is created by the shortcode so that we can keep the same effect in place without editing the core plugin itself. The issue is that we have THOUSANDS of articles currently using that shortcode, so creating a separate shortcode would involve a LOT of editing to replace the existing shortcode with a new one and honestly I am not even sure how to make one that will utilize the groups features. Which is why i am trying to figure out a hook/filter that would work or any other recommended technique.

One Response to Groups Hook for Shortcodes

  1. George February 2, 2023 at 6:08 pm #

    Hi Mike,

    The [groups_member group="group_name"]restricted content[/groups_member] basically has the usage you describe. The post author can put any sort of content enclosed in the shortcode for the privileged users. Something similar to what you describe, can also be found in the blog post How to sell Online Courses with free and paid Content, Part 1 and Part 2, where we utilise the shortcode around a piece of content that needs to be visible only to privileged users.

    To be honest, I’m still not quite sure where’s the issue exactly and how you need to customise the content that is rendered. If it’s the author who defines the content to be rendered, then there’s not much to be done honestly. The author adds the shortcode block and defines what needs to be included. On the other hand if you want to save your author’s time but also limit the content that is enclosed in groups_member shortcode, then you should go for a template. Other than the example template for 2020 you have already checked, there is also the option of the Block Editor templates that you can create and dedicate to specific post types. I’ve found this guide which might be handy for what you’re looking for.

    In general, modifying a plugin’s core without hooks should be avoided, we could offer a better suggestion if we already knew the details of your use case.

    Kind regards,

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