Skip Navigation

[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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 4 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1589139

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.

Any help is greatly appreciated.

What is the link to your site?
hidden link

#1589527

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

I found the Doc which mentioned such hooks that might be useful for you:
=> https://docs.woocommerce.com/document/subscriptions/develop/action-reference/

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.