User's End of Subscription Date
-
Hey guys, thanks for the great plugin.
Was wondering if anyone could help me with getting the date or days left for a users subscription to end. Will be a lot of help to the users so they know when to get ready to renew or upgrade their subscription level.
Thanks.
-
Hi @darlinganime,
I hope you are well today and thank you for your question.
You can get the expiry dates of member’s membership on the following path in the “Level Expires” column.
Admin Area -> Membership -> All Members
Members will find the expiry dates of their membership on the following subscriptions page that you have set in the Membership Pages settings.
https://yoursite.com/subscriptions/
Please advise if you have more questions.
Best Regards,
Vinod DalviHello Vinod,
Thanks for your response. But what I actually meant was outputting that kind of info for the user or subscriber to see on the site. Example, User 1, 50days more to end of membership subscription. For the user to see how far he or she has left for his subscription to end. Hope you get me now?
Thank you
Hi @darlinganime,
Thank you for your reply.
You can display expiry dates of current member’s membership by using the following custom code in the template file of your child theme.
<?php if(function_exists('current_user_has_subscription') && current_user_has_subscription()){ echo gmdate( 'Y-m-d H:i:s', get_user_meta( get_current_user_id(), 'expire_current_' . current_user_has_subscription(), true)); } ?>
Regards,
Vinod DalviHey Vinod,
Thanks for the code, but it doesn’t seem to work. Not displaying anything.
Hi @darlinganime,
I have tested it and it’s working fine for me.
Where have you added the code?
Please make sure the Membership plugin is active and the current current user has active subscription.
Regards,
Vinod DalviI need something like this too, but the above code does not work for me either.
I have people with more than one subscription, so I think this is the reason the above code does not work…Is there anyway to display the expiry date of a specific subscription ID? That way I can show expiry dates for all the subscriptions a member has…
Thanks
Ah, someone who it doesn’t work for too. I did not reply because I kinda gave up thinking it was just me.
Been trying everything, and membership plugin is active.
Thanks.
Hi there,
The provided code is working fine on my test site but found that it was only displaying the expiry date of first membership if the member has more than one memberships so to display expiry dates of all memberships i have modified the code as following.
<?php if(function_exists('current_user_has_subscription') && current_user_has_subscription()){ $member = new M_Membership( get_current_user_id() ); if($member->has_subscription()) { // note this could return more than one subscription so may want to check it's an array and then return the first one if only want one result $subs = $member->current_subscription(); } if(!empty($subs)) { foreach ($subs as $sub) { $sub_name = new M_Subscription( (int) $sub->sub_id ); echo '<br />'.$sub_name->sub_name(); echo ' '.date( 'Y-m-d H:i:s', get_user_meta( get_current_user_id(), 'expire_current_' . $sub->sub_id, true)); } } } ?>
Could you please try using the above code?
If for some reason it doesn’t work for you then please tell me where you are adding it and try using the following code instead of above that will provide us some debug information, just tell me what debug information you are getting if any by copy pasting it here.
<?php echo "<br /> Debug 1"; if(function_exists('current_user_has_subscription') && current_user_has_subscription()){ echo "<br /> Debug 2"; $member = new M_Membership( get_current_user_id() ); if($member->has_subscription()) { echo "<br /> Debug 3"; // note this could return more than one subscription so may want to check it's an array and then return the first one if only want one result $subs = $member->current_subscription(); } if(!empty($subs)) { echo "<br /> Debug 4"; foreach ($subs as $sub) { echo "<br /> Debug sub id ".$sub->sub_id; $sub_name = new M_Subscription( (int) $sub->sub_id ); echo '<br />'.$sub_name->sub_name(); echo ' '.date( 'Y-m-d H:i:s', get_user_meta( get_current_user_id(), 'expire_current_' . $sub->sub_id, true)); } } } ?>
Ah, someone who it doesn’t work for too. I did not reply because I kinda gave up thinking it was just me.
We invest our lot of time to develop custom solution for you and if you cooperate us then we can certainly make the solution work for you which will give us best return of our time. I am sure you understand this ??
Best Regards,
Vinod DalviOk Vinod,
I understand. Will test it and let you know if it works for me this time or not.
Thank you.
Hello Vinod,
The code works, great work. Thanks for taking time to look into it.
Thank you.
You are most welcome, if i can be of any further assistance please don’t hesitate to ask ??
Yea it works but I am trying to find a way to make a shortcode out of it because I have a page with the memberships listed, and above it I want to add the date it expires for each. So I have 3 subscriptions, and they are all free, so if someone has all three I want to be able to add something that echos the expiry date above the subscription image I have set in place. The shortcode above might be able to do that, but I guess i just dont know how to use it so it displays the information that way.
Thanks
Hi @chuyqwerty,
You can develop a shortcode as described on the following page to display this information on the page.
https://codex.www.ads-software.com/Shortcode_API
Use the code that i have posted on this thread previously to develop the shortcode but change the above code to return the content instead of echoing it using echo function as anything that is echoed will be output to the browser, but it won’t appear in the correct place on the page
As per the?Forum Welcome,you should post your own topic so if you have any further question related to it then to help keep support tickets separate, could you please open a new thread for your new question https://www.ads-software.com/support/plugin/membership
You can also include reference of this thread in your newly created thread.
We would be more than happy to help you on your new thread ??
Have a fantastic day!
Cheers,
Vinod Dalvi
- The topic ‘User's End of Subscription Date’ is closed to new replies.