Hide Price Until Login

Keyboard shortcuts
  • JNext lesson
  • KPrevious lesson
  • /Search lessons
  • EscClear search

The Hide Price Until Login module replaces all product prices with a “Login to see price” message for non-authenticated visitors. This is designed for member-only pricing, B2B wholesale stores, and private communities.

Use Cases

  • B2B wholesale stores — Keep pricing confidential from public visitors
  • Membership sites — Show prices only to registered members
  • Private communities — Gate pricing behind login for exclusivity
  • Negotiated pricing — Prevent non-customers from seeing your rates

Enabling the Module

  1. Go to Fluent Cart > GT Extensions.
  2. Toggle on Hide Price Until Login.
  3. Configure your display settings.
  4. Click Save Settings.

Settings

  • Hidden Text — Text shown instead of the price. Default: Login to see price.
  • Login Link — Make the text a clickable link to the login page. Default: Yes.
  • Hide Add to Cart — Also hide the “Add to Cart” and “Buy Now” buttons for guests. Default: Yes.
  • Redirect After Login — Redirect the user back to the product page after logging in. Default: Yes.
  • Hide for Roles — Specific WordPress user roles that should still see the hidden price message, even if logged in.
  • Show for Roles — Only show prices to users with these roles.

How It Works

The module registers hooks at priority 5 (before most other modules) to ensure prices are hidden before any other processing occurs.

Server-side:

  • fluent_cart/single_product/variation_price (priority 5) — Replaces the price HTML with the login message
  • fluent_cart/variation/data (priority 5) — Removes price data from variation responses
  • fluent_cart/product/show_add_to_cart (priority 10) — Returns false to hide buttons
  • fluent_cart/cart/validate_add (priority 5) — Returns a WP_Error if a guest tries to add items to the cart

The server-side validation is important because someone could bypass the frontend hiding and attempt to add a product to the cart via a direct request. The validation hook catches this and returns an error message: “Please login to purchase this product.”

Client-side:

The module injects JavaScript that uses a MutationObserver to replace dynamically-rendered prices. It targets these selectors:

  • .fct-price
  • .fct-variation-price
  • [data-price]
  • .fct-product-price
  • .fct-single-price
  • .fct-price-amount

When a price element is detected, it’s replaced with the login message HTML and a gtfc-price-hidden class is added to the product container.

Login Link Behavior

When Login Link is enabled, the hidden text becomes a clickable link:

<a href="/wp-login.php?redirect_to=https://yoursite.com/product/your-product/"
   class="gtfc-login-link">Login to see price</a>

The redirect_to parameter sends the user back to the current product page after successful login. If the module can’t determine the current product URL, it falls back to the home URL.

Styling

The login message is styled as a badge:

.gtfc-price-hidden-badge {
    background: linear-gradient(#f3f4f6, #e5e7eb);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.gtfc-login-link {
    color: #2563eb;
    text-decoration: none;
}

Role-Based Access

The module supports fine-grained role control:

Hide for Roles — Even logged-in users with these roles see the hidden message. Useful if you want to hide prices from subscribers but show them to customers.

Show for Roles — Only users with these specific roles can see prices. Everyone else (including other logged-in roles) sees the hidden message.

If both settings are left empty, the default behavior applies: all logged-in users see prices, all guests see the hidden message.

Shortcode

The module provides a shortcode for use in custom templates:

[gtfc_login_to_see_price text="Sign in to view pricing"]

The text attribute overrides the default hidden text. The shortcode outputs the same styled HTML as the automatic replacements.