wpmem_user_has_access()

Description

Checks if a user has access to a given membership product.

Parameters

$product
(mixed) (required) The meta key of the product being checked, or an array of product meta keys.

$user_id
(integer) (optional) The user ID to check. If no user ID is passed, it will check for the currently logged in user.

Return Value

boolean (true|false) Returns true if the user has access, otherwise false.

Example

[snippet slug=wpmem_user_has_access lang=php]

Notes

If checking multiple memberships, pass an array of the membership meta keys (slugs).  If the user has current access to any of the memberships, the function will return true.

Changelog

Introduced in version 3.2.0
Version 3.2.3 reversed the order of arguments.

Source

wpmem_user_has_access() is located in /includes/api/api-users.php.