• Resolved yamata

    (@yamata)


    Hi,

    After updating to version 4.7.0, Groups shortcodes (such as [groups_member] or [groups_non_member]) placed inside sidebar or footer widgets stop working and render empty output.

    Issue Breakdown

    In lib/views/class-groups-shortcodes.php, the newly introduced validate() method includes the following check: if ( !empty( $post->post_content ) && has_shortcode( $post->post_content, $tag ) )

    This logic assumes that shortcodes are executed exclusively within the main post/page content ($post->post_content). However, when a shortcode is executed within a widget, $post->post_content contains the main page’s content—not the widget’s content. As a result, has_shortcode() returns false, causing validate() to return FALSE and strip the shortcode output.

    Steps to Reproduce

    1. Update Groups plugin to version 4.7.0.
    2. Place a [groups_member] shortcode inside a text or block widget in a sidebar/footer.
    3. Visit a page whose main post content does NOT contain the [groups_member] shortcode.
    4. The shortcode in the widget returns empty content.

    Expected Behavior

    Shortcodes placed in widgets (or called via do_shortcode()) should evaluate correctly based on user roles and permissions, regardless of whether the shortcode exists in the main page’s $post->post_content.

    Suggested Fix

    Please reconsider relying solely on $post->post_content verification in validate(), as shortcodes in WordPress are routinely executed outside the main post content (e.g., widgets, custom fields, and template files).

    Thank you for maintaining this plugin!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Kento

    (@proaktion)

    Hi,

    Many thanks for reporting the issue!

    I’ll check this and see if we can issue an update quickly. I guess a check using the widget_display_callback filter could be suitably involved to validate shortcodes present in widgets.

    The details you have provided are very useful, again thank you very much!

    Cheers!

    Plugin Author Kento

    (@proaktion)

    FYI Groups 4.7.1 has just been released which now supports the shortcode validation in the Text and Block widget. It also provides filters which allow to integrate support for other widgets.

    ZLC

    (@kindnessville)

    Hi — I wanted to add another confirmation of this issue and note that it is still occurring with Groups 4.7.1, the current version.

    I use [groups_member] and [groups_non_member] shortcodes in a Black Studio TinyMCE sidebar widget to conditionally display access to a protected meditation workshop based on the visitor’s Groups membership.

    This setup had been working normally. With Groups 4.7.1, the conditional content in the widget no longer displays. Content immediately before and after the Groups shortcode renders normally, but everything enclosed by the Groups shortcode produces no output.

    I did some troubleshooting to rule out the widget itself and other display/sticky behavior. The Black Studio widget is processing shortcodes normally; the failure appears specific to the Groups shortcodes when they are used outside the current page/post content.

    I then rolled Groups back to the version I was using before this regression (Groups 4.6.0), with no other changes to the site, and the widget immediately began working normally again.

    This appears consistent with the previously reported issue introduced in 4.7.0 involving the new shortcode validation checking for the shortcode in the current post’s content. In my case, the shortcode isn’t in the post content—it is legitimately being processed from a sidebar widget—so the validation appears to cause Groups to return empty output.

    Since I’m seeing the same behavior in 4.7.1, it appears that whatever changed between 4.7.0 and 4.7.1 has not resolved this particular use case.

    I’ve remained on the earlier working version for now because this widget provides access to resources for my clients. I’m happy to test an updated version if a fix becomes available.

    Thank you!

    zanderm

    (@zandererecht24)

    Hello, we are continuing to experience issues with the [groups_member] and [groups_non_member] shortcodes, particularly when using them within custom HTML elements in our page builder (WPBakery).


    When we use these shortcodes in multiple places on a page, the content between them sometimes displays and sometimes doesn’t; for instance, out of four instances on a page, two might fail to appear.


    It is not yet clear what pattern governs this behavior. We have observed that if we specify only a single group as a parameter—e.g., [groups_member group="group1"]—all content displays correctly. However, problems arise as soon as more than one group is specified, such as in [groups_member group="group1,group2"].

    We would appreciate a quick fix.

    Plugin Author Kento

    (@proaktion)

    @kindnessville Thanks for reporting your issue. Version 4.7.1 adds filters that can be used to add support for non-standard widgets that are not already supported by Groups. For your case, I’ve added a solution https://github.com/itthinx/groups-bstw which you can install and activate. This is also an example of how other widgets can be integrated using the groups_shortcodes_widget_display_callback_widget_content filter.

    Plugin Author Kento

    (@proaktion)

    @zandererecht24 Thanks also to you for reporting the issue with the page builder you are using. We’ve reached out to WP Bakery to get access to the page builder for tests. Once we have that, we can check a possible solution.

    Alternatively, if using blocks is an option for you, Groups provides these blocks which can be used instead: https://docs.itthinx.com/document/groups/blocks/

    zanderm

    (@zandererecht24)

    @proaktion – thanks for the quick reply. WPBakery stores some content in Base64-encoded format. We created an mu-plugin that works for us for the time being. Here is the code.

    <?php

    /**

    * Plugin Name: Groups - WPBakery Raw Content Fix

    * Description: Workaround for Groups >= 4.7.0 shortcode validation (CVE-2026-77203 hardening) not finding [groups_member]/[groups_non_member]/[groups_can]/[groups_can_not] when they are placed inside a WPBakery "Raw HTML" ([vc_raw_html]) or "Raw JS" ([vc_raw_js]) element. Those elements store their content base64+urlencoded in post_content, so Groups' validate() re-scan never finds the literal shortcode text and silently returns empty output.

    * Author: zandererecht24

    *

    * Remove this file once itthinx ships an official fix for page-builder /

    * raw-content compatibility in Groups' shortcode validation.

    */

    if ( ! defined( 'ABSPATH' ) ) {

    exit;

    }

    add_filter( 'groups_shortcodes_validate_contents', 'yourname_groups_validate_contents_decode_vc_raw', 10, 4 );

    /**

    * Decodes WPBakery [vc_raw_html] / [vc_raw_js] blocks found in the raw

    * content and appends their decoded text, so Groups_Shortcodes::validate()

    * can find the literal [groups_member ...] / [groups_non_member ...] /

    * [groups_can ...] / [groups_can_not ...] occurrences they contain.

    *

    * @param string $contents Contents considered for shortcode validation.

    * @param string $tag Shortcode tag being validated.

    * @param array $atts Shortcode attributes.

    * @param string $content Shortcode content.

    *

    * @return string

    */

    function yourname_groups_validate_contents_decode_vc_raw( $contents, $tag, $atts, $content ) {

    if ( preg_match_all( '/\[vc_raw_(?:html|js)(?:\s[^\]]*)?\](.*?)\[\/vc_raw_(?:html|js)\]/s', $contents, $matches ) ) {

    foreach ( $matches[1] as $encoded ) {

    $decoded = rawurldecode( base64_decode( trim( $encoded ) ) );

    if ( is_string( $decoded ) && $decoded !== '' ) {

    $contents .= ' ' . $decoded;

    }

    }

    }

    return $contents;

    }
    • This reply was modified 1 month, 3 weeks ago by zanderm.
    ZLC

    (@kindnessville)

    @proaktion Thank you so much! Your solution worked like a charm. I appreciate you, Kento.

    Plugin Author Kento

    (@proaktion)

    @kindnessville Great to hear, thanks!

    Plugin Author Kento

    (@proaktion)

    @zandererecht24 Thanks for sharing this, that was very helpful! Version 4.8.0 has been released where support for the page builder has been built in based on your suggestion, so after you’ve updated to that version, you won’t need the extra plugin.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.