Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to have a content unlock within certain period of time...

    I have this website that when people register, and everyday there's a new video.

    Anyways, I was wondering how I could make it so that a certain video unlock on a daily basis for a member? Now, keep in mind that everyone registers at different times, so..

    Example:

    If "Bob" registers on April 2, the first day he gets Video one, then April 3rd, he gets Video two.

    And at the same time, let's say "Bill" registers on April 5th, I want Bill to start off with video one then on April 6th, have video two automatically unlocked for him. I don't want Bill to start off with Video four when he first registers because Bob registered 4 days before.

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    setup fields in a database and a date/time field.

    Registered put in NOW(), then have a cron job or just a login script insert to update the date difference.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #3
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm a coding newbie...would it be possible if you could be specific or find a guide on how it tells me to complete this task? If not, I understand.

  • #4
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    How do you want to set it up for the next video to be unlocked? if you register May 1st, and login again on May 4th you have 4 videos unlocked? Or do you want the person to be active every day to get a video? Lots of options.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #5
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by myfayt View Post
    How do you want to set it up for the next video to be unlocked? if you register May 1st, and login again on May 4th you have 4 videos unlocked? Or do you want the person to be active every day to get a video? Lots of options.
    Second one but, only to log in ONCE after the 24 hours.

    Example:

    May 1 at 5 PM, they register - First video unlocked
    Inactive until May 4th of 4:54 PM - Second video unlocks

    HOWEVER...

    If:

    May 1 at 5 PM, they register - First video unlocked
    May 2 at 4:54 PM, they log in...they have to wait 6 more minutes until video 2 shows.

    Regardless of the situation...they only need to log in ONCE for the video to show up. Meaning, even if they log in for a second and log out, if the appropriate time as passed, I want the next video to show.

  • #6
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    Add a field in your database called "lastlogin" and another "videonumber".
    Make the lastlogin a DATETIME, and the videonumber just a tinyint(3).

    Have a default of 0 for videonumber.

    Do a check when they login such as: if ($user['videonumber'] == 0) {
    echo "This is your first time logging in, you've unlocked your first video!";

    Do a query to add a number to the videonumber field such as SET videonumber=videonumber+1

    You need a PHP code to check date/time difference. When they login, have it check for a 24 hour between lastlogin field and current time (I am not good with date/time codes). If the difference is greater than 24 hours, do another query and do videonumber=videonumber+1

    Setup your videos to be displayed if that number is reached. Such as a loop, foreach or a static number. Such as: if ($user['videonumber'] == 5) { //SHOW VIDEO

    I am not sure how you wish to set it up.

    I hope this is helpful.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #7
    New to the CF scene
    Join Date
    Apr 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Understood some parts. Can someone be anymore specific?

  • #8
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    Well which parts don't make sense and I can explain them a bit better?
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #9
    New Coder
    Join Date
    Aug 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    You do know SQL right? myfayts advice is sound


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •