The Suma Shortcode: [suma]
Short Codes is a feature introduced in Wordpress 2.5 that allows macro codes to be inserted into the content of Posts or Pages in order to manipulate parts of that content.
Suma provides its own built-in shortcode “[suma]” using this technology which allows authors to restrict access to select parts of a Post’s content. Using shortcodes can thus be more selective than marking the entire Post as restricted, and so compliments Suma’s other mechanism for restricting access (Setting the Visibility of Restricted Posts).
The Suma short code is used to tag content. Thus it has opening and closing tags. An example of use is:
Some content here. [suma] This content will be subject to Suma’s access control rules. [/suma]. More content here.
The following arguments can be used with this tag:
- notLoggedInMsg=’msg‘ – If the tagged content is requested by a user who isn’t logged into Wordpress then Suma returns msg instead of the tagged content. Msg maybe HTML code.
- noSubscriptionMsg=’msg‘ – If the tagged content is requested by a user who is logged into Wordpress and who is a subscriber but doesn’t have any active subscriptions (e.g. their subscriptions have expired) the Suma returns msg instead of the tagged content. Msg maybe HTML code.
- inadequateSubscriptionMsg=’msg‘ – If the tagged content is requested by a user who is logged into Wordpress and who is a subscriber but doesn’t have a subscription which provides access to this content then Suma returns msg instead of the tagged content. Msg maybe HTML code.
- restrictedTo=”SubscriptionGroupName[,SubscriptionGroupName]“] – The user requesting the tagged content must have an active subscription belonging to one of the named Subscription Groups for Suma to allow them access the tagged content, otherwise Suma considers the user to have insufficient access privileges. This parameter thus modifies the access decisions of the above arguments.
- invert – Inverts the decision to replace or not replace the tagged content.
These arguments can be used in combination within the same tag.
The following examples can be used with a default installation of Suma.
Example 1. Require the user to be logged into Wordpress (with or without a subscription) in order to view the tagged content.
This is untagged content.
[suma notLoggedInMsg='You must be logged in to view this content']
Content viewable only when logged-in.
[/suma]
Resuming with regular content.
Example 2. Display a message but only to users who aren’t subscribers. This could be used for instance to display advertisements to non-members and leave members to view the Post without ads.
This is untagged content.
[suma invert noSubscriptionMsg='This text is displayed to users who aren't logged in and could have been the HTML for an advertisement'/]
Resuming with regular content.