• Resolved jarvsodesign

    (@jarvsodesign)


    Hi.
    Do you have a function to check is user is an active subscriber? For example:

    
    function your_callback_function( $user_id, $subscription_status ) {
      if ($subscription_status == 'active') {
        //User has an active subscription
      else {
        //User does NOT have an active subscription
      }
    }
    
    • This topic was modified 1 year, 4 months ago by jarvsodesign.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author WP Swings

    (@wpswings)

    Hey @jarvsodesign

    Thank you for trying our plugin Subscriptions for WooCommerce

    This block of code will return all of the active subscriptions for the current user, check here

    Regards,

    Thread Starter jarvsodesign

    (@jarvsodesign)

    Thank you. Works great. Only problem is, when the subscription ends, it is cancelled right away. Is it possible to retrieve the end date of the current user subscription?

    Thanks

    Plugin Author WP Swings

    (@wpswings)

    Hey @jarvsodesign

    So if you want to get “retrieve the end date of the current user subscription” for his any subscription order then you only things which need to subscription id for that subscription order and if you have a subscription id then you can easily retrieve the subscription end date from below code and you will get the subscription end date for that subscription order.

    $wps_susbcription_end = get_post_meta( $subscription_id, ‘wps_susbcription_end’, true );

    Regards,

    Thread Starter jarvsodesign

    (@jarvsodesign)

    Awesome. Thanks a million!

    Plugin Author WP Swings

    (@wpswings)

    Hey @jarvsodesign

    I’m hoping you are happy with our help, please share your best review if you want for us,

    Hoping you will enjoy it so much!

    Regards,

    Thread Starter jarvsodesign

    (@jarvsodesign)

    Hi. Sorry to bother you, but i now noticed it returns 0 for cancelled subscriptions. If a user has bought one month subscription, and cancel it after a few days, they have still payed for the rest of the period. And i need to find that end date.

    Thanks

    Plugin Author WP Swings

    (@wpswings)

    We have checked your latest query and you are saying it returns 0 in case of subscription is canceled but let us know inform you your product has a subscription end date then its definitely the return subscription end date for specify subscription id.

    So there is much chance you have entered the wrong subscription id. Let us an example with a proper example right, please see the below screenshot here

    Thread Starter jarvsodesign

    (@jarvsodesign)

    Hi.
    ‘wps_susbcription_end’ still returns zero. However, i was able to use ‘wps_next_payment_date’ for both active and cacelled subscriptions.

    Thanks

    Plugin Author WP Swings

    (@wpswings)

    Hey,

    Can you please be able to share a screenshot of the product edit page of that subscription product that is used in the subscription order in which you are trying to get the value subscription end date?

    It will be helpful in resolving if you can connect to our support

    Regards,

    Thread Starter jarvsodesign

    (@jarvsodesign)

    Here you have a screenshot of the edit page for a subscription:
    Image: Product edit page.
    Please not its in Swedish. And date has been changes from X days to X months after this screenshot were taken.

    Screenshot of the subscription table:
    Image: Sub table.

    And here is a screenshot of the database with the value “wps_susbcription_end”:
    Image: Database wps_susbcription_end.

    And here is a screenshot of the database with the value “wps_next_payment_date”:
    Image: Database wps_next_payment_date.

    • This reply was modified 1 year, 4 months ago by jarvsodesign.
    Plugin Author WP Swings

    (@wpswings)

    Hey @jarvsodesign

    We have checked your mentioned screenshot but please check our screenshot then check your product edit page with subscription settings which we are trying to show by the arrow in the screenshot and check the value of the subscription expiry interval.

    We think it’s blank due to which your database screenshot for wps_subscription_end value is showing 0 to you

    Please check here

    Regards,

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Function if user is active subscriber’ is closed to new replies.