How to get a list of all my subscribers in Woocommerce?

I am trying to get a list of all my subscribers in Woocommerce. I read about WC_Subscriptions_Manager :: get_subscription (), but I don't know how to use it. Please keep in mind that I have almost no knowledge of PHP.

Someone asked a similar question on the forum. I finally used the following code:

<?php if(isset($_REQUEST['Action']))
{
$Action = $_REQUEST['Action'];
switch($Action)
{
    case "ValidateSubscription":

        include('../../wp-load.php'); //Guessing this path based on your code sample... should be wp root

        $Subscriptions = WC_Subscriptions_Manager::get_all_users_subscriptions();
        print_r($Subscriptions);
        break;
    default:
        echo "invalid action";
    }
}else
    {
    echo "no action specified";
}
?>

How can i use it?

Thank you for your help!

+4
source share
1 answer

You can use wcs_get_users_subscriptions () . If you do not pass the user_id argument, the current user is used by default. The function returns all subscriptions.

+1
source

All Articles