[Resolved] Hiding Published Custom Post if a users membership has expired
This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Tell us what you are trying to do?
I am creating a directory for a client. They have a membership site using woocommerce subscriptions. I created a custom post type of their members to manager their listings. I am trying to hide listings for anyone who let's their membership expire. I can't find a way to do it with the query filter nor with the conditional block in the editor inside the loop. I tried wirting a function to check if the author is a actice subscriber but I am not having any luck. It seems to me that this should be possible but I haven't found a solution and I am hoping I might have missed it or that someone else may have come across this already.
Hello. Thank you for contacting the Toolset support.
It seems you should ask this question to WooCommerce subscriptions support as the action needs to be triggered when the subscription is expired and at that time you need to either delete posts belongs to that user or change the post status to draft.
You may try to use the hooks, so when WooCommerce subscription is expired the role will be changed.
- woocommerce_subscriptions_updated_users_role
You can use the above the hook and find all posts the whole author is the user whose subscription is expired currently and change the post status to draft and it will not display on frontend.
You can check with WooCommerce subscription support for more information about hook and ask them how you can update the post status once the subscription is expired for that user.