Reputation: 199
I am Using WooCommerce Subscribtion Plugin and I want to check is current user has an active and paid subscription on his acccount to put simple if/else in my PHP file like:
if ($subscription = 'active' && is_user_logged_in() ) {
echo "Hello";
} else {
echo "Goodbye";
}
Of course, this code is just a representation of what I want to achieve. How can I do this?
Upvotes: 1
Views: 662
Reputation: 42
Assuming you're using the default configuration, anyone that is an active subscriber has the "Subscriber" role - you could use the following;
$user = wp_get_current_user();
if ( in_array( 'subscriber', (array) $user->roles ) ) {
echo "Hello";
} else {
echo "Goodbye";
}
Upvotes: 1