Envira Gallery Documentation
Documentation, Reference Materials and Tutorials for Envira Gallery
Documentation, Reference Materials and Tutorials for Envira Gallery
The Envira Gallery Password Addon provides an extra layer of security by requiring a password to view certain galleries. By default, once accessed, the gallery uses cookies to remember that the user has entered the correct password, preventing repeated prompts. For enhanced control, you may want to adjust the duration of this cookie. This tutorial will teach you how to set a custom cookie time limit for the Envira Gallery Password Addon.
To set a custom time limit for the password protection cookie in Envira Gallery, use the following code snippet. For guidance on adding custom PHP code to your WordPress site, refer to this document.
Here’s the code snippet to implement:
/* Control the Cookie for the Password Addon * * @link https://enviragallery.com/docs/how-to-control-the-cookie-for-the-password-addon/ */ add_filter('envira_password_protection_time_limit', 'test_envira_password_protection_time_limit', 10, 3); function test_envira_password_protection_time_limit($time_limit, $post, $data) { // Note: you can use $post and $data to individually set time limit based on post ID, gallery data, etc. // Time is in seconds, so if you wanted to set the time limit for something very short (like 10 seconds) $time_limit = time() + 10; return $time_limit; }
Customizing the password protection cookie duration can offer tailored security measures for your galleries, ensuring the experience aligns with your site’s requirements. Adjusting the cookie duration can be particularly useful if you need more frequent reauthentication or longer access periods.
And that’s it! Would you like to have your gallery titles link when inside an Envira album? Take a look at our article on How to make the gallery titles in your Envira Albums link.