Page Security & Membership
[resolved] [Plugin: Page Security by Contexture] Time line for users (2 posts)

  1. msrie
    Posted 5 years ago #


    Great plugin. I was wondering about setting time frames for users, i.e. if a user has subscribed or logged in the first time is there a way to only have that username and password valid for 2 weeks or so?

    Thanks a lot,


  2. Matt van Andel
    Plugin Author

    Posted 5 years ago #

    Yes, but you'd have to get your hands dirty with a bit of code.

    There's a few ways you could do this, but here's some pointers:

    1. Start by creating an appropriate hook in your theme's functions.php file, or as a new plugin. You'd probably want to use the user_register hook.
    2. Use CTXPS_Queries::add_membership_with_expiration() to automatically register new users to a specified group with a specified expiration date (this is located in contexture-page-security/core/model_queries.php.

    Here's some code right off the top of my head that may do the trick (totally untested) - you'll need to check it to ensure the correct group id and whatnot suit your needs, of course.

    function autoregister_user($user_id){
       $group_id = 3;
       $expires = strtotime(date("Y-m-d")) . " +2 week");
       $expires = date("Y-m-d",$expires);

    Theoretically, the above will automatically enroll any newly registered user in the group with id 3, and that membership will expire two weeks from the day they registered.

    Hope this helps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Page Security & Membership
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic