Signature
$vendor_id = apply_filters( 'mam_wc_pv_register_vendor', int $vendor_id, int $user_id, string $role = 'wc_product_vendors_pending_vendor', ?string $vendor_name = null );
| Parameter | Type | Description |
|---|---|---|
$vendor_id |
int |
Pass 0. If a non-zero id is supplied the filter is a pass-through and creates nothing (lets later callbacks short-circuit). |
$user_id |
int |
Existing WordPress user id to become the vendor’s first admin. |
$role |
string |
Role to set on the user, e.g. wc_product_vendors_pending_vendor (manual approval) or wc_product_vendors_manager_vendor / wc_product_vendors_admin_vendor. |
$vendor_name |
string|null |
Optional explicit vendor (term) name. When null, the canonical handler derives firstname-lastname-userid. |
Returns: the new vendor’s wcpv_product_vendors term id on success, or false on failure (e.g. the user id does not resolve).
When to use this instead of the action
Use mam_wc_pv_register_vendor (filter) when you need the new vendor id back, or when you need to pass a custom vendor name. Use mam_wc_pv_process_vendor_registration (action) when you only need the side effect and don’t care about the return value.
Both are the REPO_BOUNDARIES-compliant alternative to instantiating mam_woocommerce_product_vendors_general_functions directly. Internally both run the same vendor_registration_form_process() core.
// Create a vendor named after a place/listing, then store the id on that listing.
$vendor_id = apply_filters(
'mam_wc_pv_register_vendor',
0,
$user_id,
'wc_product_vendors_admin_vendor',
$place_title
);
if ( $vendor_id ) {
update_user_meta( $user_id, 'parent_pv_account_id', $vendor_id );
update_post_meta( $place_id, 'par_vendor_id', $vendor_id );
}
What the registered handler does
The canonical handler (priority 10) runs vendor_registration_form_process():
- Inserts a new
wcpv_product_vendorsterm (named$vendor_name, orfirstname-lastname-useridwhen not supplied). - Sets the term’s
vendor_datameta with the user as the only admin. - Copies the user’s billing meta (address, city, state, zip, phone) into the vendor’s term metas and geocodes the address (requires the
tsl-google-api-keyoption for coordinates). - Marks the vendor
typeasparent. - Replaces the user’s role with
$role(viawp_update_user). - Emails the site
admin_emaila “New Seller Account Pending” notice.
Notes
- The handler does not check capabilities — the caller is responsible for deciding the user may become a vendor and for choosing a safe
$role. Do not pass roles taken from request input; validate first. - The role is set, not added: the user’s previous role is replaced.
- The filter only has a handler when WooCommerce Product Vendors is active; guard with
has_filter()if your plugin may run without it. - After creating the vendor you typically fire
do_action( 'mam_wc_pv_vendor_registration_completed', $vendor_id )for downstream integrations.
Related articles
- Hook:
mam_wc_pv_process_vendor_registration(action variant, no return value) - Recipe: Vendor onboarding and registration
- Hook:
mam_pv_assignable_roles
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-woocommerce-product-vendors |
| Applies to plugin version | 26.26.1+ |
| Category | Extending MAM Suite |
| Hook type | filter |
| Audience | PHP developer / integrator |
| Last verified | 2026-06-26 |
