Abstract Shortcodes class is by other products to help with shortcodes implementation. This class has different features that can help with basic attributes for shortcodes, handle functions calls for rendering and to handle access limitation based on user roles and capabilities.
Products using gdr2_Shortcodes
- xScape Theme Framework (from 1.8.3, with access control)
- GD Custom Posts and Taxonomies Tools Pro (from 3.7, with access control)
- GD Products Center Pro (from 1.1.1, with access control)
More products will support this, and that includes: GD Products Center and GD Star Rating.
Access Control with Attributes
You can limit shortcode rendering so that you can hide content from some users (or visitors). There are several attributes added to shortcodes that will control this limitation. Each shortcode for supported products will have these attributes. If you don’t include one of the access attributes, that type of limitation will not be used.
- Limit by logged status: Basic limitation is for logged users. Use ‘access_logged’ attribute set to true or false to show content for the shortcode to logged users or to visitors only.
- Limit by user role: Name of the role so that only users with that role can see the content. Use ‘access_role’ attribute and set it to the role you want to limit the content to.
- Limit by capability: Name of the capability so that only users with that capability can see the content . Use ‘access_caps’ attribute and set it to the capability you want to limit the content to.
Once you set this, some of the users or visitors will be limited to see the content. Instead of content they will get nothing, or you can set it to display a message. This message has 3 additional attributes, and it will be displayed with DIV tag: ‘access_message’, ’access_class’ and ‘access_style’.
So, here is the example of the xss_infobox shortcode in the xScape Theme Framework with the limitation active:
[xss_infobox color="red" access_logged=true access_message="Access Denied" access_class="denied"]This is the content to limit[/xss_infobox]
This will show content only to logged users, visitors will see Access Denied message, in DIV with ‘denied’ class.
Access Control with Filters
You can also control access using WordPress filters. Depending on the product and the shortcode, filter name will be different. Basic format is to have prefix that is product specific and the name of the shortcode. Prefix can be:
- for xScape Theme Framework: xss_access_shortcode_
- for GD Custom Posts and Taxonomies Tools Pro: gdcpt_access_shortcode_
- for GD Products Center Pro: gdpc_access_shortcode_
So, for the shortcode xss_info in xScape, filter name would be: xss_access_shortcode_xss_info. Return true or false through the filter handling function to show or hide content.





