How can I determine if a user has already signed up a product

As I can find out, the user has already bought a member file.

I am looking for something like this:

if(have_subscription){ 
   //code to add button
}else{
   // code to add something else
}

Thanks in advance!

+4
source share
1 answer

This should be pretty simple using the built-in features of UserPress:

if(current_user_can('memberpress_authorized')) {
  // Do authorized only stuff here
}
else {
  // Do unauthorized stuff here
}

MemberPress also adds features for each MemberPress membership so you can also do something like this:

if(current_user_can('memberpress_product_authorized_123')) {
  // Do authorized only stuff here
}
else {
  // Do unauthorized stuff here
}

In the second example, the number 123 is the MemberPress membership identifier.

+4
source

All Articles