Guides implementation of the CrestApps Orchard Core Memberships module, which sells product-based access with role grants, membership periods, and content gating. Covers MembershipPart, MembershipService, order event handling, background expiration, and deployment steps.
Ships in crestapps-orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Memberships sells access. Attach the Membership part to a product type; buying the product puts the buyer in the part's roles for its length, buying again adds time, and a cancellation, a full refund, the end date or the store takes the roles away. Whatever those roles gate (content restricted with Content Access Control, permissions, features) opens and closes with the membership.
Memberships is a one-off purchase through an order. For a renewing, billed-every-cycle plan with roles, use Subscriptions and its entitlements (orchardcore-subscriptions). Related skills: orchardcore-carts and orchardcore-orders (orders and IOrderEventHandler), orchardcore-products, orchardcore-checkout, orchardcore-content-access-control, orchardcore-crestapps-roles. To sell courses, learning paths or course seats instead of roles, use Learning Commerce (orchardcore-learning).
| Feature ID | Depends on | Fills |
|---|---|---|
CrestApps.OrchardCore.Memberships (MembershipsConstants.Feature) | Commerce, CrestApps.OrchardCore.Orders, OrchardCore.Roles | IOrderEventHandler, ICartLineHandler |
Install CrestApps.OrchardCore.Memberships in the web project. The Memberships sample recipe (MembershipsSample) enables Contents, Roles, Content Access Control, Products, Carts, Orders, Checkout and Memberships, creates a Member role, a members-only Members' Article type with one article, and a $49 Annual Membership product.
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.ContentAccessControl",
"CrestApps.OrchardCore.Orders",
"CrestApps.OrchardCore.Checkout",
"CrestApps.OrchardCore.Memberships"
],
"disable": []
}
]
}
MembershipPart: RoleNames (string array) and DurationDays (default 365; 0 or less never ends).
{
"steps": [
{
"name": "ContentDefinition",
"ContentTypes": [
{
"Name": "MembershipPlan",
"DisplayName": "Membership Plan",
"Settings": { "ContentTypeSettings": { "Creatable": true, "Listable": true, "Draftable": true, "Versionable": true } },
"ContentTypePartDefinitionRecords": [
{ "PartName": "TitlePart", "Name": "TitlePart", "Settings": { "ContentTypePartSettings": { "Position": "0" } } },
{ "PartName": "ProductPart", "Name": "ProductPart", "Settings": { "ContentTypePartSettings": { "Position": "1" }, "ProductPartSettings": { "Type": "Service", "DefaultCurrency": "USD", "SalesMode": "Purchasable", "PriceDisplay": "Show" } } },
{ "PartName": "MembershipPart", "Name": "MembershipPart", "Settings": { "ContentTypePartSettings": { "Position": "2" } } }
]
}
]
},
{
"name": "Content",
"data": [
{
"ContentItemId": "annualmembership000000000a",
"ContentType": "MembershipPlan",
"DisplayText": "Annual Membership",
"Latest": true,
"Published": true,
"TitlePart": { "Title": "Annual Membership" },
"ProductPart": { "Price": 49, "Currency": "USD", "Sku": "MEMBER-ANNUAL", "IsPurchasable": true },
"MembershipPart": { "RoleNames": [ "Member" ], "DurationDays": 365 }
}
]
}
]
}
MembershipOrderEventHandler.GrantAsync calls MembershipService.GrantAsync(order): for each membership line it creates a Membership or extends the member's active one for that product with MembershipPeriods.Extend(now, currentEnd, DurationDays, quantity) (from the current end while it has not passed, else from now; null end for an unlimited part). It grants the roles through IRoleGrantService (CrestApps.OrchardCore.Users.Abstractions, services.AddRoleGrants() from Users.Core), which records each grant on the user by source (Membership) and source id (the membership); new memberships leave AddedRoleNames empty. Line roles and length are read from the product version the order bought. When the buyer is the signed-in user on the request, their sign-in is refreshed so the roles apply at once; paid by webhook, the sign-in catches up later. A guest's order grants nothing.RevokeOrderAsync ends the memberships it bought. Refunded: only when the order is refunded in full (OrderRefundStatus.Refunded).EndAsync(membership, status, reason)): revokes the membership's role grants; the member leaves a role only when the membership put them in it and nothing else (another membership, a subscription) still grants it. The security stamp is then updated so an existing sign-in is re-validated. MembershipRoleGrantSource reports the roles of memberships made before grants were recorded (from AddedRoleNames), so they are kept and removed as before.MembershipsBackgroundTask (Membership end dates, 15 * * * *) calls ExpireAsync.MembershipCartLineHandler refuses a membership line to a guest (Sign in to buy ...).Membership (collection Memberships, MembershipIndex): UserId, UserName, ContentItemId, Title, RoleNames, AddedRoleNames, OrderIds, StartsUtc, EndsUtc, Status, EndedReason. IMembershipStore: ListByUserAsync, ListByOrderAsync(userId, orderId), ListEndedAsync, PageAsync(search, status, skip, take).
The Memberships step creates or updates memberships. The member is named by UserName (must exist on the site); a membership is matched by ItemId, then by member, product (ContentItemId) and StartsUtc. An active imported membership grants its RoleNames through role grants. The Memberships deployment step (Commerce) writes every membership without the member's user id or AddedRoleNames.
{
"steps": [
{
"name": "Memberships",
"Memberships": [
{ "ItemId": "4ms00000000000000000000001", "UserName": "ana", "ContentItemId": "4gold0000000000000000000001", "Title": "Gold", "RoleNames": [ "Member" ], "StartsUtc": "2026-01-01T00:00:00Z", "EndsUtc": "2027-01-01T00:00:00Z", "Status": "Active" }
]
}
]
}
Attach RolePickerPart with RolePickerPartContentAccessControlSettings.IsContentRestricted = true to the content type (Content Access Control). RoleBasedContentItemAuthorizationHandler then refuses View content to anyone not in one of the item's roles, anonymous visitors included, even when the permission is granted to everyone. Administrators see every item.
The same pattern serves any "paid order grants X" module. Derive from OrderGrantHandlerBase (CrestApps.OrchardCore.Orders.Core.Services), which routes paid orders to GrantAsync and canceled or fully refunded orders to RevokeAsync. When the grant comes from a part on the product, OrderLineGrantHandlerBase<TPart> (as Memberships and Downloads use) reads each line's purchased product version and skips lines already granted:
using CrestApps.OrchardCore.Orders.Core.Models;
using CrestApps.OrchardCore.Orders.Core.Services;
public sealed class CourseSeatOrderHandler : OrderGrantHandlerBase
{
protected override Task GrantAsync(Order order, CancellationToken cancellationToken)
{
// Enroll order.UserId in the courses on order.Lines. When the order is paid through the checkout this
// runs inside the completing transaction: throwing rolls the completion back for a retry.
return Task.CompletedTask;
}
protected override Task RevokeAsync(Order order, OrderRevokeReason reason, CancellationToken cancellationToken)
{
// reason is OrderRevokeReason.Canceled or Refunded.
return Task.CompletedTask;
}
}
// services.AddScoped<IOrderEventHandler, CourseSeatOrderHandler>();
memberships, ManageMemberships, on Orchard Core's AdminList): member, roles, end date (shown in the site's time zone), status filter, End now (no refund).account/memberships (route AccountMemberships, shape AccountMemberships) lists the member's own memberships in the commerce account menu.| Symptom | Cause |
|---|---|
| Paid but content still hidden | Sign-in not refreshed (paid by webhook); sign out and in, or wait for the security stamp check |
| Role kept after a refund | Only a full refund ends a membership |
| Role kept after ending | Another active membership gives the same role, or the member had the role before |
| Guest cannot add to cart | By design; a membership needs an account |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
orchard-core, memberships, paid-roles, content-access-control, ecommerce
/crestapps-orchardcore:orchardcore-membershipsfrom crestapps-orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-orchardcore137 skills in this plugin
/orchardcore-accountsSkill for the CrestApps Orchard Core Accounts module (CrestApps.OrchardCore.Accounts) with its Account Members, Account Team, Account E-mail Domains and Account Locations features. Covers the Account type and AccountPart, the account picker and search, IAccountChildTypeRule, account page sections (AccountPageTabs, AddPageSection, Notes), members and IAccountMemberService, account invitations, the account owner and team picked from staff, e-mail domains, locations with a billing location, the account's billing profile and party members, the Accounts recipe and deployment steps, and the admin menu. Use this skill when requests mention accounts, the businesses or households records belong to, an account page tab, members, invitations, owners, domains or locations. Strong matches include AccountPart, AccountPageTabs, IAccountMemberService, IAccountInvitationService, AccountInvitation, AccountTeamPart, AccountEmailDomainsPart, IAccountEmailDomains, AccountLocationsPart and ManageAccountMembers./orchardcore-accounts-b2bSkill for the CrestApps Orchard Core Accounts B2B module (CrestApps.OrchardCore.Accounts.B2B), business selling on an Account content item. Covers B2BAccountPart and B2BAccount, buyers as account members and ship-to addresses as account locations, terms (deposit, net days, credit limit) through the account-terms tender billed to the account, the account's billing profile, purchase order numbers, quotes, price lists through IBuyerPriceProvider, order limits, approvals and budgets, OCI punchout, the account/business page and API, the PriceLists recipe and deployment steps, the B2BAccounts report source, and the move from the removed Companies module. Use this skill when requests mention B2B, wholesale or business buyers, net terms, purchase orders, price lists, order approvals or punchout. Strong matches include B2BAccountPart, B2BAccount, AccountTerms, AccountTermsTenderProvider, B2BAccountBillingProfileSource, IB2BAccountStore, PriceList, B2BPriceProvider, B2BApprovalService and ManageB2BAccounts.Other plugins' skills for the same job