Triggering a timewall after X days

I'm looking to implement a sort of timewall for a Wordpress website. The process for this would be the next:

  • User accesses the site for first time (non-logged user).
  • After 3 days, user is asked to register in order to see the content.
  • User registers (logged user) and has access to content.
  • After a month user membership ends and becomes non-logged user again.
  • User has 3 days again to see content before being asked to register

Is there a way to achieve that using a cookie, for example? Is there a control for private browser navigation or IP switching?

I found this to trigger something after one day, but I'm not sure it fits with what I need:

$datetime1 = date_create(); // now
$datetime2 = date_create($last_log);

$interval = date_diff($datetime1, $datetime2);

$days = $interval-format('%d'); // the time between your last login and now in days

if(strtotime($last_log)  strtotime('-1 day')){
    // it's been longer than one day
}

Thanks a lot in advance!

Topic cookies php Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.