post_password_expires

Filters the life span of the post password cookie.

Description

apply_filters( 'post_password_expires', (int) $time ); 

By default, the cookie expires 10 days from creation. To turn this into a session cookie, return 0.

Parameters (1)

0. $time (int) => time() + 10 * DAY_IN_SECONDS
The expiry time, as passed to setcookie().

Usage

To run the hook, copy the example below.
  1. $time = apply_filters( 'post_password_expires', $time ); 
  2.  
  3. if ( !empty( $time ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the post_password_expires callback 
  2. function filter_post_password_expires( $time ) { 
  3. // make filter magic happen here... 
  4. return $time
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'post_password_expires', 'filter_post_password_expires', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'post_password_expires', 'filter_post_password_expires', 10, 1 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-login.php  
  1. $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );