• Resolved leonardus

    (@leonardus)


    Have you a suggestion for setting timeout in protected password page?
    if I change setting in wp-pass or in wp-login, with an update my modify are overwritten…
    is there a plugin to do this?

    sorry for my english… thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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

    Moderator bcworkz

    (@bcworkz)

    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.

    Thread Starter leonardus

    (@leonardus)

    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.

    Thread Starter leonardus

    (@leonardus)

    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);
    }
Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘timeout password protected page wp 3.9.2’ is closed to new replies.