I'm developing a website in WordPress with WooCommerce. I'm using additionally WC Paid Listings and WooCommerce Subscriptions plugins to handle my work.
The problem is when a user with "subscriber" role with an active subscription login and try to post a content every time he / she has to choose a package even he has an active subscription.
Is there anyone with an idea of how to detect if user has an active subscription, if it returns true then the step choosing package skipped?
Thanks.
Updated (2019)
wcs_user_has_subscription()
.The following custom conditional functions have an optional argument
$user_id
(a defined user_id) and will returntrue
when the current user (or a defined user) has active subscriptions.So this can be done now using 3 different ways (that do the same thing):
1) Using WooCommerce Subscriptions dedicated conditional function
wcs_user_has_subscription()
:2) The same thing with a much lighter SQL query (added on March 2019):
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
3) The original enhanced code, that will also do the same:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Update of usage:
1) USAGE for the current user:
2) USAGE for a defined user ID:
This code is tested and it works
Related answers:
Use
wcs_user_has_subscription()