Description
Sets user access for a given product.
Parameters
$membership
(string) (required) The meta key of the product to set access for.
$user_id
(integer) (optional) The user ID to assign access to. If no user ID is passed, it will set the product for the currently logged in user.
$date
(string|date|boolean) (optional) The user’s expiration date for the membership in either MySQL date format (YYYY-MM-DD 00:00:00) or simply YYYY-MM-DD. Default value is false and the expiration will be set from the current date.
Return Value
boolean (true|false) Returns true if setting the membership was successful.
Examples
[snippet slug=wpmem_set_user_membership lang=php]
Changelog
- Introduced in versionĀ 3.4.2
Source
wpmem_set_user_product() is located in /includes/api/api-users.php.