• Resolved vladnice

    (@vladnice)


    Hello,

    I would like to know if it is possible to grant access to all content to users who are not logged in, but just for a short period of time. After, x minutes, I would like all unlogged users to be redirected to a login page.

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Joachim Jensen

    (@intoxstudio)

    Currently this is not supported out of the box, but it would be possible grant access to any user for a period of time with something like this:

    add_filter('rua/user/global-access', function($has_access, $user) {
        $temp_access_time = 5*60; //5 minutes
        if($user->ID > 0) {
            return $has_access;
        }
        if(!isset($_COOKIE["rua-limited-access-".$user->ID])) {
            setcookie("rua-limited-access-".$user->ID,time());
        } elseif($_COOKIE["rua-limited-access-".$user->ID] + $temp_access_time > time()) {
            $has_access = true;
        }
        return $has_access;
    });

    Obviously this is a very simple method of doing it, and it could be improved by storing the access in a database instead of a cookie.

    I hope this helps!

    Thread Starter vladnice

    (@vladnice)

    Thank you for your reply!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Timed access’ is closed to new replies.