Signature
$on_account = apply_filters( 'mam_pv_check_user', bool $on_account, int $user_id, int $vendor_id );
| Parameter | Type | Description |
|---|---|---|
$on_account |
bool |
Seed/previous result — pass false; it is also the fallback when the user has no vendors |
$user_id |
int |
The user to test |
$vendor_id |
int |
The vendor term id to test membership against |
Returns true when the user belongs to the vendor; otherwise the incoming $on_account value.
When it fires
Whenever a consumer applies it. This plugin registers the canonical handler (priority 10, 3 args), which returns true if $vendor_id appears in WC_Product_Vendors_Utils::get_all_vendor_data( $user_id ) — i.e. the user is listed on that vendor’s staff. In-plugin consumers include:
- the seller content classes (vendor products, profile, all-orders, content blocks) — each verifies the acting user against their
mam_current_vendor_accountbefore rendering vendor data; - the vendor account switch on initial phone data — a vendor-id switch request is honored only if this filter passes.
Example — ownership test before acting on a vendor
$user_id = mam_user_id();
$vendor_id = (int) get_user_meta( $user_id, 'mam_current_vendor_account', true );
if ( ! apply_filters( 'mam_pv_check_user', false, $user_id, $vendor_id ) ) {
return; // not this user's store
}
// safe to act on $vendor_id for $user_id
Example — grant a support role implicit membership
add_filter( 'mam_pv_check_user', function ( $on_account, $user_id, $vendor_id ) {
if ( ! $on_account && user_can( $user_id, 'mam_support_agent' ) ) {
$on_account = true;
}
return $on_account;
}, 20, 3 );
Notes
- This is a pure membership check — it does not consider
manage_woocommerce. For operation-level decisions (orders, products, locations, approval, roles) use the richermam_wc_pv_user_can_*filters, which include the store-manager override and deny-by-default semantics. - The default handler never returns
falseexplicitly; it returns your seed value when membership isn’t found — always seed withfalsefor a strict test.
Related articles
- Hooks: `mam_wc_pv_usercan` authorization filters*
- Recipe: Staff manager configuration
- Plugin: mam-woocommerce-product-vendors
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-woocommerce-product-vendors |
| Applies to plugin version | 26.19.1+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer / integrator |
| Last verified | 2026-06-10 |
