• Resolved msrie

    (@msrie)


    Hi,

    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,

    Marie

Viewing 1 replies (of 1 total)
  • Plugin Author Dutch van Andel

    (@veraxus)

    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.

    add_action('user_register','autoregister_user',10,1);
    function autoregister_user($user_id){
       $group_id = 3;
       $expires = strtotime(date("Y-m-d")) . " +2 week");
       $expires = date("Y-m-d",$expires);
       CTXPS_Queries::add_membership_with_expiration($user_id,$group_id,$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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Page Security by Contexture] Time line for users’ is closed to new replies.