本文へ移動
cccskills
無料GitHub で公開

wcm-access-discounts

WooCommerce Memberships access, restriction, drip-content, product-grant, and member-discount playbook. Use when code checks whether a user can view/purchase content or products, changes scheduled access dates, customizes protected/public content, maps parent or variation products that grant membership access, applies member prices, reads original prices around discounts, or contains wc_memberships_user_can, wc_memberships_access_from_time, wc_memberships_user_has_member_discount, wc_memberships_get_member_product_discount, wc_memberships_get_discounted_price, or member discount badge hooks.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md12.5 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

WooCommerce Memberships: access and discounts

Use this when an integration needs to decide whether a user can access content/products, alter restriction behavior, adjust drip-content timing, grant access from products, or work with member prices. This is where generic WooCommerce or WordPress assumptions most often produce subtle bugs.

Misconception this skill corrects

"Membership access is a simple active-status check, and member discounts are just a product price filter."

Memberships combines plan rules, user membership status, access start time, delayed/dripped access, product/category restrictions, purchase restrictions, product grants, and price-adjustment filters. Use the public capability/discount APIs and the Memberships filters at the rule layer.

When to use this skill

Trigger when ANY of the following is true:

  • The user asks "can this member view/buy/access", "hide protected product", "drip content", "scheduled access", "member discount", "membership price", "grant access product", or "original price before discount".
  • Code contains wc_memberships_user_can(), wc_memberships_is_post_content_restricted(), wc_memberships_is_product_viewing_restricted(), wc_memberships_access_from_time, wc_memberships_user_object_access_start_time, wc_memberships_user_has_member_discount(), wc_memberships_get_member_product_discount(), or wc_memberships_get_discounted_price.
  • You are writing WooCommerce price filters in a store that uses Memberships.

Access checks

Prefer wc_memberships_user_can() for final "can this user do this" decisions:

if ( wc_memberships_user_can( $user_id, 'view', array( 'post' => $post_id ) ) ) {
    myplugin_show_content();
}

if ( wc_memberships_user_can( $user_id, 'purchase', array( 'product' => $product_id ) ) ) {
    myplugin_allow_purchase();
}

Useful public helpers:

NeedAPINotes
Post content restricted?wc_memberships_is_post_content_restricted( $post_id )Tells whether Memberships restricts the object, not whether a specific user has access.
Term restricted?wc_memberships_is_term_restricted( $term_id, $taxonomy )Useful for category archives/custom taxonomies.
Product viewing restricted?wc_memberships_is_product_viewing_restricted( $product_id )Product-level viewing rules.
Product purchasing restricted?wc_memberships_is_product_purchasing_restricted( $product_id )Use if available in installed version for purchase-only rules.
User active member?wc_memberships_is_user_active_member( $user_id, $plan )Membership status check, not rule/object access.
User active or delayed member?wc_memberships_is_user_active_or_delayed_member( $user_id, $plan )Useful for drip UX where membership exists but access is not yet open.

Do not replace wc_memberships_user_can() with a raw membership status check when the target object matters.

Restriction and drip hooks

NeedHookTypeArgsUse
Change rule access start timestampwc_memberships_access_from_timefilterint $from_time, WC_Memberships_Membership_Plan_Rule $rule, WC_Memberships_User_Membership $membershipMain drip-content timing extension point. Return a Unix timestamp.
Override object access start timewc_memberships_user_object_access_start_timefilterint $access_time, array $argsOverride calculated access start time for a target object/rule args.
Force content publicwc_memberships_is_post_publicfilterbool $public, int $post_id, string $post_typeBypass restrictions for selected content.
Public-content cache TTLwc_memberships_public_content_cache_expirationfilterint $expirationAdjust cache lifetime for public-content lookups.
Products granting accesswc_memberships_products_that_grant_accessfilterarray $product_ids, int $object_id, string $rule_type, array $args, array $unfilteredChange product IDs shown as granting access to protected objects.
Products granting access to term query argswc_membership_get_products_that_grant_access_to_term_argsfilterarray $argsNote singular wc_membership. Adjust lookup query.
Feed restrictionwc_memberships_is_feed_restrictedfilterbool $restrictedControl restricted feed output.
Restrictable comment typeswc_memberships_restrictable_comment_typesfilterstring[] $typesInclude/exclude comment types from restriction behavior.
Rule object IDswc_memberships_rule_object_idsfilterarray $ids, WC_Memberships_Membership_Plan_Rule $ruleAdjust objects a rule applies to.
Rule prioritywc_memberships_rule_priorityfilterint $priority, $ruleResolve conflicts between rules.
Rule access timewc_memberships_rule_access_start_timefilterint $access_time, int $from_time, WC_Memberships_Membership_Plan_Rule $ruleLower-level rule access timing.

There is not a single universal wc_memberships_user_can result filter to "just allow access". Change the rule inputs, public-content decision, access start time, or membership status intentionally.

Product grants

NeedHook/APITypeUse
Product in order grants plan accesswc_memberships_access_granting_purchased_product_idfilterChoose parent/variation or multiple product IDs used for the grant.
Access granted from purchasewc_memberships_grant_membership_access_from_purchaseactionReact after purchase grants membership. Args include order/product/user/membership context.
Order grant metadatawc_memberships_get_order_access_granted_memberships(), wc_memberships_has_order_granted_access(), wc_memberships_set_order_access_granted_membership()APIRead or mark which memberships an order granted.
Force account at checkoutwc_memberships_force_checkout_registrationfilterEnsure a guest can become a user before access is granted.

When a variable product grants access, check whether the plan expects the parent product, variation, or both. The grant filter is also used by checkout registration logic, so return IDs that really grant the selected plan.

Member discount APIs

NeedAPINotes
Product has any member discountwc_memberships_product_has_member_discount( $product )Product-level rule availability.
User has discount for productwc_memberships_user_has_member_discount( $product, $member )Use for current-user eligibility. $member can be user/membership context.
Get discount amount/rulewc_memberships_get_member_product_discount( $membership, $product, $formatted = false )For display or external sync.
Badge HTMLwc_memberships_get_member_discount_badge( $product, $variation = false )Use rather than recreating badge markup.

Member discount hooks

NeedHookTypeArgsUse
Stack discountswc_memberships_allow_cumulative_member_discountsfilterbool $allow, int $user_id, WC_Product $productAllow several plans/rules to cumulate.
User discount eligibilitywc_memberships_is_user_eligible_for_member_discountsfilterbool $eligible, int $user_idGlobal user-level discount gate.
Exclude productwc_memberships_exclude_product_from_member_discountsfilterbool $excluded, WC_Product $productProduct-level exclusion.
Discounted pricewc_memberships_get_discounted_pricefilter$price, $base_price, int $product_id, int $user_id, WC_Product $productFinal price extension point. Return numeric price-like value.
Rounding precisionwc_memberships_discount_rounding_precisionfilterint $precisionMatch store/accounting needs.
Price filter prioritywc_memberships_price_adjustments_filter_priorityfilterint $priorityCoordinate with other dynamic pricing plugins.
Product discount rules for userwc_memberships_product_purchasing_discount_rules_for_userfilterarray $rules, WP_User $user, WC_Product $productAdd/remove discount rules before price calculation.
Use discount formatwc_memberships_member_prices_use_discount_formatfilterbool $use_discount_formatControl sale/strike-through style.
Price HTMLwc_memberships_get_price_html, wc_memberships_get_discounted_price_html, wc_memberships_get_price_html_before_discount, wc_memberships_get_price_html_after_discountfilterCustomize displayed price HTML.
Sale price displaywc_memberships_member_prices_display_sale_pricefilterbool $display_sale_priceControl how sale price and member price interact.
Product sale state while discountedwc_memberships_product_is_on_sale_before_discount_excluded_filtersfilterarray $filtersCoordinate sale checks with price filters.
Badge HTMLwc_memberships_member_discount_badge, wc_memberships_variation_member_discount_badgefilterCustomize badge text/markup.

Price adjustment recursion safety

Memberships adjusts WooCommerce product prices through filters. If your code needs the original WooCommerce price while Memberships discounts are active, disable Memberships adjustments only around that read and re-enable them immediately.

do_action( 'wc_memberships_discounts_disable_price_adjustments' );

$product = wc_get_product( $product_id );
$regular_price = $product ? $product->get_regular_price() : null;

do_action( 'wc_memberships_discounts_enable_price_adjustments' );

For price HTML only:

do_action( 'wc_memberships_discounts_disable_price_html_adjustments' );
$html = $product->get_price_html();
do_action( 'wc_memberships_discounts_enable_price_html_adjustments' );

Do not leave adjustments disabled across template rendering, cart calculation, REST responses, or async callbacks.

Common mistakes

// WRONG: active membership is not the same as access to this protected object.
if ( wc_memberships_is_user_active_member( $user_id, $plan_id ) ) {
    echo get_post_field( 'post_content', $post_id );
}

// RIGHT: ask Memberships for access to the target object.
if ( wc_memberships_user_can( $user_id, 'view', array( 'post' => $post_id ) ) ) {
    echo apply_filters( 'the_content', get_post_field( 'post_content', $post_id ) );
}

// WRONG: custom price filter can double-discount or recurse through Memberships.
add_filter( 'woocommerce_product_get_price', function ( $price, $product ) {
    return wc_memberships_get_member_product_discount( get_current_user_id(), $product );
}, 10, 2 );

// RIGHT: use Memberships discount filters or APIs at their intended layer.
add_filter( 'wc_memberships_get_discounted_price', function ( $price, $base_price, $product_id, $user_id, $product ) {
    if ( myplugin_should_cap_member_price( $product_id, $user_id ) ) {
        return min( $price, 99 );
    }

    return $price;
}, 10, 5 );

// WRONG: drip access by comparing post dates or membership start meta yourself.
$can_view = strtotime( get_post_meta( $membership_id, '_start_date', true ) ) < time();

// RIGHT: alter access start time or call the final access API.
add_filter( 'wc_memberships_access_from_time', function ( $from_time, $rule, $membership ) {
    if ( myplugin_rule_uses_external_unlock( $rule ) ) {
        return myplugin_get_unlock_timestamp( $membership->get_user_id(), $rule );
    }

    return $from_time;
}, 10, 3 );

Cross-references

  • Use wcm-membership-hooks for creation, status transitions, profile fields, REST/webhooks, members area, CSV, admin, and Subscriptions-linked membership hooks.
  • Use wc-variations-pricing-filters when combining Memberships discounts with custom variation price logic and cached variation price hashes.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

Control a headless browser to navigate URLs, click elements, fill forms, extract content from JavaScript-rendered pages, take screenshots, and automate end-to-end web workflows.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

Review code for quality, simplicity, and maintainability. Identifies unnecessary abstractions, duplicated logic, oversized functions, missing error handling, and naming issues — then fixes them automatically before presenting the result.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

WooCommerce store operations through NV oOS Pro — product research, catalog cross-referencing, inventory lookups, and Shopify or Flowhub comparisons where integrations are configured.

日本語の概要は準備中です。原文の説明を表示しています。

nvdigitalsolutions/mcp-ai-wpoos72026年10月13日 更新

nvdigitalsolutions のスキルをすべて見る

このスキルの問題を報告する