Shortcode Validation – When Shortcodes aren’t Processing
When you put a Groups shortcode inside certain third-party plugins (like custom page builders, table creators, or advanced layout containers), the shortcode might simply show up empty or as plain text instead of working.
This happens because Groups includes a built-in security feature: it scans the standard WordPress post content to verify that a shortcode was actually written there before it allows it to run. However, many third-party plugins store their content in specific fields, custom database tables or layout blocks. Because Groups cannot find the shortcode where it would expect it and validate it, it blocks it from processing for safety reasons. As the shortcodes that come with Groups relate to access restrictions and restricted content, this is a critical security feature.
How to approach this
If you are experiencing this issue on your site, you will need to bridge the gap between the third-party container plugin and the Groups plugin.
- The Fix: A small snippet of code needs to be added to your website. Usually via a child theme’s
functions.phpfile, a custom plugin or by using a code snippet plugin like Code Snippets. - What it does: It uses a specialized hook called
groups_shortcodes_validate_contents. This hook tells the Groups plugin: “Hey, also look inside this specific third-party plugin’s content when validating security, so it’s safe to process the shortcodes.” - Next Step: You will likely need to share the developer guide below with your developer or the support team of the third-party plugin you are using so they can give you the exact field that contains additional content to scan, the database table or content reference names.
Implementation Guide
This section is intended for developers.
The Groups plugin validates shortcode presence inside its Groups_Shortcodes::validate() method by checking the targeted content against content that is accepted. The groups_shortcodes_validate_contents filter allows you to append third-party or custom-stored content strings directly to this validation pool.
Conceptual Example
You can hook into the groups_shortcodes_validate_contents filter to query and pull content from metadata, custom fields, or global layout variables associated with the current page.
This example assumes that extended content that can contain shortcodes is stored as custom post meta using the meta key '_custom_extended_content'. A new function custom_groups_shortcodes_validate_contents is hooked to the groups_shortcodes_validate_contents filter and looks for the presence of the custom meta for the current post. If it is found, the additional content is appended and made available to Groups for shortcode validation.
function custom_groups_shortcodes_validate_contents( $contents, $tag, $atts, $content ) {
// the current post
$post_id = get_the_ID();
if ( ! $post_id ) {
return $contents;
}
// append custom content to content used for shortcode validation
$extended_content = get_post_meta( $post_id, '_custom_extended_content', true );
if ( !empty( $extended_content ) && is_string( $extended_content ) ) {
$contents .= $extended_content;
}
return $contents;
}
add_filter( 'groups_shortcodes_validate_contents', 'custom_groups_shortcodes_validate_contents', 10, 4 );
Concrete Examples
Twenty Ten Child Page Template
This is child theme that implements validating dynamic shortcodes in templates.
WPBakery Page Builder
The Groups_WPBakery class implements shortcode validation based on decoded content.
