Possible to automatically lock a post after a certain amount of time?

not afaik with wp-members, but i use https://projectdmc.org/plugins/post-expirator/ now known as Publishpress Future. it adds the ability to schedule changes in status to a post:

Enable Future Action->action->change status->new status->private

…is that “status” change, the wp-members status?

I want to automatically make posts members-only (WP-Membership plugin managed members) after a certain time, without having to go in by hand and change them. So I can write a post, schedule it for posting having it be public, then automatically have it be members-only at a later date…

Yes it would be possible, but it would be done with some custom code snippets you’d need to apply (either in your theme’s functions.php file or wherever you store custom code snippets).

Whether a post is blocked, unblocked, or hidden is determined by a post meta value _wpmem_block. The values are:

  • 0 = unblocked
  • 1 = blocked
  • 2 = hidden

If there is no _wpmem_block meta key, then it is considered to be whatever the default setting is for that post type (i.e. if posts are blocked by default and there is no _wpmem_block meta value, then the post is blocked).

What you’d need to do is create a scheduled event in WP that would run through post publish dates and if a post is (a) past the determined time period and (b) is not already blocked, then add the _wpmem_block meta with a value of 1 for that post.

Thanks for the breadcrumbs! That makes me think…

Is there a hook in the plugin, that is just before the plugin decides if a post can be displayed?

I could hook in my code there. To change a post to protected, just before it’s checked for display.

I’m going to send emails “new post, you have X days to read it” to non-members. Then flip to blocked (either doing it by hand, or with hooked in code) that post after the number of days. So freebie subscribers can read if they’re quick. Members can of course read anything any time.

  • This reply was modified 1 hour, 24 minutes ago by cconstantine.

Yes – that’s actually probably better/easier than running a scheduled event.

You could use the wpmem_block filter hook, which fires when a post’s block value is checked. This filter passes the post ID, so you could:

  • check the post’s publish date
  • if the publish date is past X, set the _wpmem_block meta accordingly
  • return the wpmem_block value as true for blocked



This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer