Fluentcart customers portal

From Lonsdale201/wp-agent-skills · View interactive version

Fluentcart customers portal is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Implements and audits FluentCart customer identity, WP_User linkage, addresses, ownership checks, account creation, customer-scoped queries, and custom portal endpoints. Use when working with Customer, CustomerResource, getCurrentCustomer(), fct_customers, customer-profile REST routes, fluent_cart_a

How to use this skill

Skill file

FluentCart customers and portal

Treat Customer as the commerce identity and WP_User as an optional login

identity. Enforce ownership for every customer-facing object.

Read customer-identity.md before changing

email/user links, moving resources, or exposing customer data.

Resolve identity safely

Customer IDs, not WP user IDs.

user_id or matching email and may attach that user_id to the existing row.

duplicate/merge consequences before changing an address.

Use Customers/CustomerResource and the normal resource-moving hooks for

coordinated changes. Do not update order and subscription customer_id values

piecemeal.

Enforce object ownership

CustomerFrontendPolicy only proves that a WP user is logged in. It does not

authorize an arbitrary order, subscription, address, download, or license.

For every custom handler:

  1. resolve CustomerResource::getCurrentCustomer();
  2. query the requested object with customer_id equal to that customer;
  3. reject absent/mismatched objects without revealing whether another customer

owns them;

  1. authorize the requested mutation separately;
  2. use FluentCart lifecycle methods for the mutation.

Never authorize solely by UUID, license key, address ID, download ID, or portal

URL.

Add a portal page

Register at fluent_cart/init or later. Use a unique kebab-case slug that is not

dashboard, purchase-history, subscriptions, licenses, downloads, or profile.

~~~php

fluent_cart_api()->addCustomerDashboardEndpoint('acme-benefits', [

'title' => __('Benefits', 'acme-addon'),

'render_callback' => static function (): void {

$customer = \FluentCart\Api\Resource\CustomerResource::getCurrentCustomer();

if (!$customer) {

return;

}

echo '<div>' . esc_html__('Your benefits', 'acme-addon') . '</div>';

},

]);

~~~

The render callback receives no arguments and echoes content inside the logged-in

portal shell. Escape output and recheck any resource ownership inside it. A

page_id can be supplied instead, but its content must still avoid exposing

unscoped customer data.

Keep caches request-scoped

CustomerResource caches the current customer statically. Call

resetCurrentCustomerRuntimeCache() between simulated users/requests in PHPUnit,

WP-CLI loops, workers, or multisite switches. Do not let one user's cached

Customer bleed into another iteration.

Handle account and email changes

create/link an account according to store/order policy.

cases.

fluent_cart/customer_resources_moved only after verifying their payload.

Cross-references

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.