You can use “hook” functions in many cases to do this.
In your (hopefully child) theme, you add a function, and register that function as a HOOK which WordPress calls at various stages of its processing, there are a great many hooks available.
The basic documentation is here:
http://codex.ww.wp.xz.cn/Plugin_API section “Hooks, Actions and Filters”
A comprehensive list of the available hooks are here:
http://adambrown.info/p/wp_hooks
Specifically, I believe you will want to use the ‘post_password_expires’ filter. Your filter callback would simply return the UNIX timestamp when the password should expire.
mmm… is too difficult for me…
I don’t use a child theme… and I can’t add a function… I don’t know how…
while I try to understand something about API and HOOKS, have you a simpler suggestions like a plugin?
thank for your suggestion.
ok… I’ve find a plugin very good for my case.
I send to all the link…
http://ww.wp.xz.cn/plugins/content-protector/
Thanks very much.
You can make it expire with the session. Just add this to your child theme’s functions.php file or create a plugin:
add_action( 'wp', 'post_pw_sess_expire' );
function post_pw_sess_expire() {
if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
// Setting a time of 0 in setcookie() forces the cookie to expire with the session
setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH);
}
Thanking you big time @ leonardus for recommending and sharing link for content-protector. The hand written code when inserted (inside an Elegant Themes template) deleted my clients’ site –fortunately I had backed up .php the necessary files :S This plugin is perfect for my clients’ needs. Thanks again!
Hi,
I found that because your code did’nt work for me on WP 4.1.1.
Hope that helps
add_action( 'wp', 'post_pw_sess_expire' );
function post_pw_sess_expire() {
if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
// Setting a time of 30 min in setcookie() forces the cookie to expire after that duration
setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], time() + 60 * 30, COOKIEPATH);
}