How can I detect if user has already bought a memberpress product.
I’m searching something like this:
if(have_subscription){
//code to add button
}else{
// code to add something else
}
How can I detect if user has already bought a memberpress product.
I’m searching something like this:
if(have_subscription){
//code to add button
}else{
// code to add something else
}
You must be logged in to post a comment.
This should be pretty straight forward using MemberPress’ built in capabilities:
MemberPress also adds capabilities for each MemberPress Membership so you could also do something like this:
In the second example the number 123 is the id of the MemberPress membership.
The answer from 2015 didn’t work for me but is a top search result. I thought I should share the result of my search here for others in the future.
Also, I think that “product_authorized” capability only checked if a purchase was made, not verifying the expiration date.
So here is how MemberPress determines if active, inactive, or none:
has_expired()
can return true even if the user is active from a separate transaction so don’t rely on that alone.If you need to check a specific membership you can use the following:
is_already_subscribed_to()
accepts only a product idis_active_on_membership()
accepts any of: product id, MeprProduct, MeprTransaction, or MeprSubscriptionYou can also get all of a user’s active subscriptions with:
Open your WordPress website and:
Plugins > Add New
Upload Plugin > Choose file
MemberPress
plugin from your saved filesInstall Plugin > Activate
You will now find
MemberPress
has been added to your WordPress dashboard.This should help.