1. Documentation
  2. Restrict Content
  3. [gamipress_restrict_content]

[gamipress_restrict_content]

Restrict a portion of content.

Common Attributes:

  • id – Identifier for this portion of content.
  • unlock_by – Defines how users can get access to this portion of content. Accepts: expend_points, points_balance, achievement, achievement_type, all_achievement_type, rank Default: expend_points
  • granted_roles – Manually grant access to this portion of content to users by role. Accepts any registered role or a comma-separated list of roles
  • granted_users – Manually grant access to this portion of content to the users you want. Accepts any user ID or a comma-separated list of user IDs
  • message – Text that is shown to users that haven’t unlocked this portion of content.
  • guest_message – Text that is shown to non logged in users.

Important: Remember that you need to close the shortcode:
[gamipress_restrict_content]{content}[/gamipress_restrict_content]

id attribute

When restricting with the [gamipress_restrict_content] shortcode, the content inside can’t be identified in anyway, for that, the id attribute lets you to give it an identity and brings you some possibilities.

1) Placing content with different id
When you place the [gamipress_restrict_content] shortcode, you can bring to each portion an unique id. Each portion with different id needs to get unlocked separately and meeting each condition of each portion of content.

Note: If you don’t provide the id attribute, an internal id will be generated for this portion of content.

2) Placing content with the same id
At the moment the user unlocks a portion of content, the id assigned to this portion is assigned with the unlock entry. Until this moment, Restrict Content will bring access to all portions of content that uses the same id.

You can use this feature to restrict different portions of content on different pages and make all of them get unlocked at the same time at the moment the user meets the requirements configured.

Unlock by expending points (unlock_by=”expend_points”)

Setting unlock_by attribute to expend_points will restrict the portion of content through expending points. A button will be displayed in order to let user expend the amount if they want to see this portion of content.

Attributes:

  • points – Points amount required to unlock this portion of content.
  • points_type – The points amount points type required to unlock this portion of content. Accepts any registered points type slug

Example: [gamipress_restrict_content id="content-123" unlock_by="expend_points" points="100" points_type="credits" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Unlock by reaching a points balance (unlock_by=”points_balance”)

Setting unlock_by attribute to points_balance will restrict the portion of content requiring to the user reach a specific points balance. At the moment that user reaches the total balance, will be able to see the portion of content.

Important: If user expends or gets deducted points and doesn’t meets the conditions, access will be revoked automatically.

Attributes:

  • points – Points amount required to unlock this portion of content.
  • points_type – The points amount points type required to unlock this portion of content. Accepts any registered points type slug

Example: [gamipress_restrict_content id="content-123" unlock_by="points_balance" points="100" points_type="credits" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Unlock by unlocking achievement(s) (unlock_by=”achievement”)

Setting unlock_by attribute to achievement will restrict the portion of content requiring to the user to earn a specific achievement or a group of specific achievements. At the moment that user unlocks all of this achievements, will be able to see the portion of content.

Important: If user lost any of the achievements required (eg, get them revoked or by transfer them) and doesn’t meets the conditions, access will be revoked automatically.

Attributes:

  • achievement – A comma-separated list of the achievement(s) required to unlock this portion of content.

Single achievement example: [gamipress_restrict_content id="content-123" unlock_by="achievement" achievement="1" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Multiple achievement example: [gamipress_restrict_content id="content-123" unlock_by="achievement" achievement="1,2,3" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Unlock by unlocking any achievements of type (unlock_by=”achievement_type”)

Setting unlock_by attribute to achievement_type will restrict the portion of content requiring to the user to earn a specific amount of achievements of a specific type. At the moment that user unlocks the required amount of this achievements, will be able to see the portion of content.

Important: If user lost any of the achievements required (eg, get them revoked or by transfer them) and doesn’t meets the conditions, access will be revoked automatically.

Attributes:

  • achievement_type – The achievement type required to unlock this portion of content.
  • achievement_count – Number of achievements required to unlock this portion of content.

Example: [gamipress_restrict_content id="content-123" unlock_by="achievement_type" achievement_type="badge" achievement_count="5" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Unlock by unlocking all achievements of type (unlock_by=”all_achievement_type”)

Setting unlock_by attribute to all_achievement_type will restrict the portion of content requiring to the user to earn all the achievements of a specific type. At the moment that user unlocks all of this achievements, will be able to see the portion of content.

Important: If user lost any of the achievements required (eg, get them revoked or by transfer them) and doesn’t meets the conditions, access will be revoked automatically.

Attributes:

  • achievement_type – The achievement type required to unlock this portion of content.

Example: [gamipress_restrict_content id="content-123" unlock_by="all_achievement_type" achievement_type="badge" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Unlock by reaching a specific rank(s) (unlock_by=”rank”)

Setting unlock_by attribute to rank will restrict the portion of content requiring to the user to reach a specific rank or a group of specific ranks. At the moment that user reaches all of them, will be able to see the portion of content.

Important: If user gets downgraded to a lower priority rank that required one (eg, get them revoked or by transfer them) and doesn’t meets the conditions, access will be revoked automatically.

Attributes:

  • rank – A comma-separated list of the rank(s) required to unlock this portion of content.

Single rank example: [gamipress_restrict_content id="content-123" unlock_by="rank" rank="1" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

Multiples ranks example: [gamipress_restrict_content id="content-123" unlock_by="rank" rank="1,2,3" message="This content is restricted"]
Content to show to users that got access
[/gamipress_restrict_content]

How can we help?