Filter: mam_wc_pv_register_vendor

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():

  1. Inserts a new wcpv_product_vendors term (named $vendor_name, or firstname-lastname-userid when not supplied).
  2. Sets the term’s vendor_data meta with the user as the only admin.
  3. 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-key option for coordinates).
  4. Marks the vendor type as parent.
  5. Replaces the user’s role with $role (via wp_update_user).
  6. Emails the site admin_email a “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.


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
Contents

    Need Support?

    Can't find the answer you're looking for? Don't worry we're here to help!