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

[gamipress_show_content_if]

Show a portion of content if user meets a specific condition.

Common Attributes:

  • condition – Defines the condition that user needs to meet to show the portion of content. Accepts: points_greater, points_lower, achievement, achievement_type, all_achievement_type, rank Default: points_greater
  • granted_roles – Manually grant access to show 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 show 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 doesn’t meets the condition.
  • guest_message – Text that is shown to non logged in users.

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

Condition: Reaching a points balance greater than (condition=”points_greater”)

Setting condition attribute to points_greater will require to your users to have a points balance greater than the required amount to show the portion of content.

Important: If user lost points and is current balance is lower than required and doesn’t meets the condition, access will be revoked automatically.

Attributes:

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

Example: [gamipress_show_content_if condition="points_greater" points="100" points_type="credits" message="You need to earn 100 credits"]
Content to show to users that got access
[/gamipress_show_content_if]

Condition: Reaching a points balance lower than (condition=”points_lower”)

Setting condition attribute to points_lower will require to your users to have a points balance lower than the required amount to show the portion of content.

Important: If user earns points and is current balance is greater than required and doesn’t meets the condition, access will be revoked automatically.

Attributes:

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

Example: [gamipress_show_content_if condition="points_lower" points="100" points_type="credits" message="You have more than 100 credits"]
Content to show to users that got access
[/gamipress_show_content_if]

Condition: Unlocking achievement(s) (condition=”achievement”)

Setting condition attribute to achievement will require to your users to have earned a specific achievement or a group of specific achievements to show the portion of content. 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 condition, access will be revoked automatically.

Attributes:

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

Single achievement example: [gamipress_show_content_if condition="achievement" achievement="1" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

Multiple achievement example: [gamipress_show_content_if condition="achievement" achievement="1,2,3" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

Condition: Unlocking any achievements of type (condition=”achievement_type”)

Setting condition attribute to achievement_type will require to your users to have earned a specific amount of achievements of a specific type to show the portion of content. 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 show this portion of content.
  • achievement_count – Number of achievements required to show this portion of content.

Example: [gamipress_show_content_if condition="achievement_type" achievement_type="badge" achievement_count="5" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

Condition: Unlocking all achievements of type (condition=”all_achievement_type”)

Setting condition attribute to all_achievement_type will require to your users to have earned all the achievements of a specific type to show the portion of content. 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 show this portion of content.

Example: [gamipress_show_content_if condition="all_achievement_type" achievement_type="badge" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

Condition: Reaching a specific rank(s) (condition=”rank”)

Setting condition attribute to rank will require to your users to have reached a specific rank or a group of specific ranks to show the portion of content. 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 show this portion of content.

Single rank example: [gamipress_show_content_if condition="rank" rank="1" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

Multiples ranks example: [gamipress_show_content_if condition="rank" rank="1,2,3" message="This content is restricted"]
Content to show to users that got access
[/gamipress_show_content_if]

How can we help?