FCHubFCHub.co

Shortcodes & Blocks

Frontend shortcodes and Gutenberg blocks for restricting content, showing membership status, displaying drip progress, and building member account pages.

FCHub Memberships provides 4 shortcodes and 2 Gutenberg blocks for adding membership-aware functionality to your frontend pages.

Shortcodes

A wrapping shortcode that shows or hides its inner content based on membership access.

Usage:

[fchub_restrict plan="pro"]
This content is only visible to Pro members.
[/fchub_restrict]

Parameters:

ParameterTypeDefaultDescription
planstring''Comma-separated list of plan slugs. Member must have at least one of these plans
resource_typestring''WordPress resource type to check (e.g., post, page). Defaults to current post's type
resource_idstring''Resource ID to check. Defaults to current post ID
messagestring''Custom restriction message for non-members. Falls back to the global default
show_loginstring'yes'Show a login button for logged-out visitors (yes or no)
drip_messagestring''Custom message for drip-locked content. Supports {date} placeholder

Behavior:

  1. Not logged in — Shows the restriction message with an optional login button
  2. Logged in, no access — Shows the restriction message
  3. Logged in, drip locked — Shows the drip message with the unlock date
  4. Logged in, has access — Shows the wrapped content

Examples:

Restrict by plan:

[fchub_restrict plan="pro,enterprise"]
Premium content here.
[/fchub_restrict]

Restrict with custom messages:

[fchub_restrict plan="pro" message="Upgrade to Pro to read this." drip_message="This lesson opens on {date}."]
Lesson content here.
[/fchub_restrict]

Restrict by specific resource:

[fchub_restrict resource_type="page" resource_id="42"]
Content protected by page 42's membership rules.
[/fchub_restrict]

Post Context

When resource_type and resource_id are not specified, the shortcode defaults to checking the current post. This means you can use [fchub_restrict plan="pro"] inside any post and it will check if the current user has the Pro plan.

Gutenberg Blocks

FCHub Memberships registers two Gutenberg blocks that provide the same functionality as the shortcodes but with a visual editor interface.

fchub-memberships/restrict Block

The content restriction block wraps inner blocks and restricts visibility based on membership.

Block Attributes:

AttributeTypeDescription
plan_slugsstringComma-separated plan slugs
resource_typestringResource type to check
resource_idstringResource ID to check
restriction_messagestringCustom message for non-members

This block uses server-side rendering — it calls the same Shortcodes::renderRestrict() method as the shortcode. In the block editor, you see a visual wrapper around the inner content with plan configuration in the sidebar inspector.

fchub-memberships/membership-status Block

Displays the membership status, equivalent to the [fchub_membership_status] shortcode.

Block Attributes:

AttributeTypeDescription
displaystringcompact or full

Also uses server-side rendering via Shortcodes::renderMembershipStatus().

Editor Assets

The block editor loads:

  • assets/js/blocks.js — block registration scripts (depends on wp-blocks, wp-element, wp-block-editor, wp-components, wp-i18n)
  • assets/css/frontend.css — shared frontend and editor styles

Frontend CSS

All shortcodes and blocks enqueue fchub-memberships-frontend stylesheet (assets/css/frontend.css). This provides styling for:

  • .fchub-membership-restricted — restriction message container
  • .fchub-plan-badge — plan name badges
  • .fchub-drip-progress — progress bar track and fill
  • .fchub-content-library — content list in account page
  • .fchub-content-locked — locked content items with dates
  • .fchub-btn — button styling (login, CTA)
  • .fchub-membership-account — account page layout
  • .fchub-membership-history — history section

The CSS uses neutral colors and clean layout. You can override any styles in your theme's stylesheet since the plugin styles use standard specificity.

On this page