Show/Hide Page Content Using Shortcodes
Page content (text, images, video, etc) can be shown/hidden on a WordPress page/post using shortcodes. While shortcodes can be entered manually, it is usually more efficient to use the aMember Shortcode Editor. You can reach this editor two ways, as shown below.
Click on the minimized aMember Shortcodes Help panel (shown in the image below). This panel is located just below the aMember Protection Panel.
Click on the aMember shortcode icon in the page editor's menu bar (as shown in the image below).
The aMember Shortcode Editor will then open up as shown below. The Short Code Editor supports four types of shortcodes.
- User Information Shortcodes
- System Information Shortcode
- Content Display Shortcodes for Guests (Covered on this Page)
- Content Display Shortcodes Based on Subscriptions (Covered on this Page)
Content Display Shortcodes for Guests
Hover over [am4guest][/am4guest] and then click on the "Open" link that appears. The Content Display Shortcodes for Guests section will then open up and look like the image below. You can type the listed shortcode into the page editor or hover over a shortcode and click on the "insert" link that appears.
Any page content (text, image, video, or even other shortcodes) placed between the [am4guest][/am4guest] shortcodes will only be shown to guests (someone on the site but not logged in).
Content Display Shortcodes Based on Subscriptions
Hover over [am4show][/am4show] and then click on the "Open" link that appears. The Content Display Shortcodes Based on Subscriptions section will then open up and look like the image below. You can type the listed shortcode into the page editor or hover over a shortcode and click on the "insert" link that appears.
The visibility of page content can be finely controlled using the aMember "Show" shortcodes. Due to the complexity of the shortcode syntax, it is best to use the shortcode builder.
In the example above, all content placed between the [am4show] tags will be visible to a user with the following credentials:
- The user has an active subscription to the Educator Area (Product ID = 2) that is at least 5 days old, but not over 10 days old. - AND-
- The user has an active subscription to Site Registration (Product ID = 3)
Show Shortcode Syntax Explained
'Product Type 1, Start Day*, End Day*;Product Type 2, Start Day*, End Day*'
- = Optional
|Product Types||px||Subscription Product with an ID of "x"|
|p-1||User owns any subscription product|
|gx||Group (Category) with an ID of "x"|
|g-1||User owns any Group (Category)|
|Start Day||0,1,2,...||This is the number of days since the beginning of a subscription that content would first be visible. This value is optional; however, a "0" would be required as a place holder to enter an End Day value.|
|End Day||1,2,3...||After this number of days since the beginning of a subscription the content would be hidden. This value is optional.|
|-1||This sets the End Day to not expire.|
|user_error=||error_name||Use this to assign any aMember error to a user that is not allowed to see the content.|
|guest_error=||error_name||Use this to assign any aMember error to a guest that is not allowed to see the content.|
Examples of the Shortcode Syntax
Show block for users who have active product #2 or Group of access #1
Show block for users who have active product #1 and product was purchased not more then 10 days ago also show block for users who have product #2 and product was purchased not less then 30 days ago but not more then 60 days ago.
Show block for users who purchase product 1 not less then ten days ago, and have active subscription for product 2 stop value can be set to -1 as well. If stop value will be set to -1, block will be displayed even if user's subscription to product expired.
Means that block will be displayed for users who purchase product #1 before (even if subscription expired already)
Show block for users who have any product and product was purchased not less then 10 days ago but not more then 20 days ago
Block will be displayed if user don't have product #1 and don't have product #2
have='p1' user_error='amember_error' guest_error='amember_guest_error'
This block will be be displayed only if user have active subscription to product 1. If user don't have such subscription, 'amember_error' message will be displayed instead of block contents. Guest will see 'amember_guest_error' message.