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 the product was purchased not less than 30 days ago and not more than 60 days ago.
Show block for users who purchased product #1 not less then ten days ago, and have an active subscription for product #2. The stop value can be set to -1 as well. If the stop value is set to -1 the block will be displayed even if the user's subscription to the product has expired.
Means that block will be displayed for users who purchase product #1 before (even if the subscription expired already).
Show block for users who have any product and product was purchased not less then 10 days ago but not more than 20 days ago.
Block will be displayed if the user does not have product #1 and does not have product #2
have='p1' user_error='amember_error' guest_error='amember_guest_error'
This block will be be displayed only if the user has an active subscription to product #1. If the user does not have a subscription an 'amember_error' message will be displayed instead of block contents. The guest will see the 'amember_guest_error' message.