What they are
Every PII- or state-sensitive ride-share operation runs a deny-by-default authorization check and then passes the verdict through a filter. The default rules cover the standard rider/driver/manager model; the filters are the escape hatch for sites with custom roles. The acting user is always resolved server-side via mam_user_id() — never from request parameters.
manage_woocommerce (store manager/admin) passes every default rule.
Signatures and default rules
apply_filters( 'mam_wc_ride_share_user_can_cancel_ride', bool $allowed, int $order_id, int $user_id );
Gates ride cancellation (mam_cancel_current_ride subaction). Default allow: the order’s customer, or manage_woocommerce.
apply_filters( 'mam_wc_ride_share_user_can_update_ride', bool $allowed, int $order_id, int $user_id );
Gates ride state advances and GPS/location writes (mam_ride_share_driver_update, mam_gps_ping). Default allow: the ride’s assigned driver (driver_id order meta), or manage_woocommerce.
apply_filters( 'mam_wc_ride_share_user_can_view_ride', bool $allowed, int $order_id, int $user_id, bool $is_customer );
Gates the service-details block (customer phone, both addresses, live driver GPS). $is_customer tells you which disclosure set is being built: true → the rider view (default allow: the order’s customer), false → the driver view (default allow: the assigned driver). manage_woocommerce overrides either way.
apply_filters( 'mam_wc_ride_share_user_can_view_driver_locations', bool $allowed, int $user_id );
Gates the driver-location directory (every fleet driver’s name, duty status, and real-time GPS). Default allow: wc_product_vendors_admin_vendor (manager), or manage_woocommerce.
apply_filters( 'mam_wc_ride_share_user_can_invite_driver', bool $allowed, int $user_id );
Gates the Invite Driver form (minting/sending enrollment codes). Default allow: wc_product_vendors_admin_vendor, or manage_woocommerce.
apply_filters( 'mam_wc_ride_share_user_can_assign_driver', bool $allowed, int $user_id );
Gates the manager assign-a-ride flow (booking with an explicit driver_id, which bypasses zip matching and distance billing). Default allow: wc_product_vendors_admin_vendor, or manage_woocommerce.
Example — let a custom dispatcher role manage rides
add_filter( 'mam_wc_ride_share_user_can_view_driver_locations', function ( $allowed, $user_id ) {
return $allowed || user_can( $user_id, 'dispatch_rides' );
}, 10, 2 );
add_filter( 'mam_wc_ride_share_user_can_update_ride', function ( $allowed, $order_id, $user_id ) {
return $allowed || user_can( $user_id, 'dispatch_rides' );
}, 10, 3 );
Notes
- These run on the hot request path (home-screen builds, GPS pings) — keep callbacks fast and avoid extra queries where possible.
- Returning
trueunconditionally re-opens the PII disclosures the defaults exist to prevent. Always scope grants to a role/capability. - Returning a non-boolean truthy/falsy value works but is discouraged; return a strict
bool.
Related articles
- Plugin: mam-woocommerce-ride-share
- Hook:
mam_ride_share_driver_updateand the ride meta contract
Metadata
| Field | Value |
|---|---|
| Article type | Hook Reference |
| Plugin slug | mam-woocommerce-ride-share |
| Applies to plugin version | 1.3.1+ |
| Category | Extending MAM Suite |
| Hook type | filter (×6) |
| Audience | PHP developer |
| Last verified | 2026-06-10 |
