Gatemi Private Store Developer Reference

The free edition applies no filters or actions of its own. Everything under Filters and Actions is the full edition's.

Filters — Full edition

gmpv_verdict

The access verdict for one product, one category or the store.

Argument Type
$verdict array allowed (bool), reason (open, login, role, password), rule (the refusing rule or null)
$product_id int The product (a variation's parent), or 0
$term_id int The category, or 0

The returned array must keep allowed and reason. The verdict is asked by the query filter, visibility, purchasability, add-to-cart, the cart check and the page guard alike, so one filter changes all of them.

// Let a logged-in customer with a paid membership through every rule.
add_filter( 'gmpv_verdict', function ( $verdict ) {
	if ( ! $verdict['allowed'] && is_user_logged_in()
		&& get_user_meta( get_current_user_id(), 'has_membership', true ) ) {
		$verdict['allowed'] = true;
		$verdict['reason']  = 'open';
		$verdict['rule']    = null;
	}
	return $verdict;
} );

gmpv_rules

The stored rules as read. Whatever you return is normalised again, so an unknown scope or access is read the strictest way.

gmpv_settings

The merged settings array. Must return an array.

gmpv_modules, gmpv_license_api_url, gmpv_update_cache_ttl

The module list, the gatemi.com licensing endpoint and the update payload's cache time in seconds.

Actions — Full edition

gmpv_booted

Fires once the plugin's modules have booted, with the service container.

Storage

gmpv_settings

Key Default Edition
enabled no Both
hide yes Both
refused message Full
login_url '' Full
unlock_ttl 86400 Full

gmpv_rules

A list of rules, each:

array(
	'id'       => 'trade-only',
	'label'    => 'Trade only',
	'scope'    => 'categories',   // store | categories | products
	'terms'    => array( 12, 18 ),
	'products' => array(),
	'access'   => 'roles',        // login | roles | password
	'roles'    => array( 'wholesale_customer' ),
	'password' => '',              // a wp_hash_password() hash, password rules only
	'message'  => '',
);

The free edition reads and writes only the rule with the id private-store, and only its scope and terms.

To set a password rule in code, pass a plain password as new_password through the screen, or store wp_hash_password( 'secret' ) in password. Never store a plain password.

gmpv_unlocked, written with wc_setcookie() (HTTP-only). Its value is up to 20 dot-separated 64-character tokens, each hash_hmac( 'sha256', $rule_id . '|' . $password_hash, wp_salt( 'auth' ) ). Exclude it from server-level caches along with WordPress' login cookies.

Form fields

The password form posts gmpv_unlock_form, gmpv_rule, gmpv_password and a _wpnonce for the action gmpv_unlock, handled on template_redirect at priority 5.

Where the plugin hooks in

Hook Purpose
pre_get_posts Remove protected products from product queries (with Hide on)
woocommerce_product_is_visible Visibility (with Hide on)
get_terms Remove protected categories from lists and menus (with Hide on)
woocommerce_is_purchasable, woocommerce_variation_is_purchasable Not purchasable
woocommerce_add_to_cart_validation Refuse with a reason
woocommerce_check_cart_items Remove a protected product from a cart
template_redirect (8, 10) No-cache headers; the page guard
template_include (999) The refused page

Template override

Copy templates/protected.php to yourtheme/gatemi-private-store/protected.php. The plugin uses the theme's copy when one exists. A copy made from one edition's template calls that edition's own classes, so make it from the edition you run.

CSS classes

The stylesheet private.css is loaded on storefront pages while protection is on.

Class Element
gmpv-protected The <main> of the refused page
gmpv-protected-title, gmpv-protected-message Heading and sentence
gmpv-login The paragraph holding the Sign in button
gmpv-unlock, gmpv-unlock-label, gmpv-unlock-input, gmpv-unlock-button, gmpv-unlock-error The password form (Full edition)
Shopping Cart
Scroll to Top