tribe_tickets_ticket_in_wc_membership_for_user( int $ticket_id, int $user_id )
Checks if the specified user (defaults to currently-logged-in user) belongs to any active WooCommerce Membership plans, *and* if the specified ticket (by ticket ID) has any active member discounts applied to it. It may not be the user’s membership plan specifically, so this template tag *may* produce some false positives.
Contents
Parameters
- $ticket_id
-
(int) (Required)
- $user_id
-
(int) (Required)
Return
(bool)
Source
File: src/template-tags/tickets.php
function tribe_tickets_ticket_in_wc_membership_for_user( $ticket_id, $user_id = 0 ) {
if (
! function_exists( 'wc_memberships_get_user_active_memberships' ) ||
! function_exists( 'wc_memberships_product_has_member_discount' )
) {
return false;
}
$user_id = 0 ? get_current_user_id() : $user_id;
$user_is_member = wc_memberships_get_user_active_memberships( $user_id );
$ticket_has_member_discount = wc_memberships_product_has_member_discount( $ticket_id );
return $user_is_member && $ticket_has_member_discount;
}
Changelog
| Version | Description |
|---|---|
| 4.7.3 | Introduced. |