Add an option to restrict articles older than X days

  • jan44
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 days 21 hours ago #169737 by jan44
Hello!

I’m trying to add a new option to the Membership Pro plugin to restrict access to articles after a certain number of days (e.g., after 3 days, articles would be viewable only by members). Currently, the plugin has an option to release articles after X days, but I need to do the opposite. 

What I’ve Tried:

Plugin Code (osmembershiparticles.php):

I identified the isArticleReleased function, which currently makes articles available after X days. I think I could create a similar function, like isArticleRestrictedAfterDays, to restrict instead.
Configuration (osmembershiparticles.xml):

I added a new field, restrict_articles_after_x_days, to specify the number of days before restriction. It appears in the settings, but I’m unsure how to fully integrate it.
Templates (form.php, advanced.php):

Added input fields to show the new setting for administrators.

Could you advise on how to:

Properly implement a restriction function like isArticleRestrictedAfterDays?
Integrate this function with the current plugin logic?
Any guidance would be appreciated. Thank you!

Or maybe the best it to create new plugin (copy of origianl one) to keep this working in case of updates ?

Thanks a lot !

Please Log in or Create an account to join the conversation.