Support » Fixing WordPress » post_password_expires

  • Resolved ripriprip


    I would like to use this code, to be sure that the password would need to be entered upon each new session. as indicated here:

    However, I don’t have a child theme, so I can’t change the code as mentioned here.

    I’m am learning, so terminology is hard for me.
    Can someone show me where the “0” is suppose to go in this code snip?

    function Modif_expir_cookie( $time ) { 
      return time() + 600 ;  // 10 mn
      // for 5 minutes :  
      // return time() + 300;  in this case 60 * 5 
      // return 0; set cookie to expire at the end of the session
    add_filter('post_password_expires', 'Modif_expir_cookie' );

    Can I put it into my plugin called “Code Snippets”? (free version)

    If I can, can someone explain how to do that?

    or I guess I just put it into my theme’s functions.php file? But then I have to worry about it every time the theme upgrades?

    Thank you in advance, Tammy

    • This topic was modified 1 year, 7 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Prin a11n


    Hello there,

    I understand you would like to use the code that you mentioned on your site.

    Yes, you can use the Code Snippets plugin ( to do this.

    After installing and activating the plugin:
    1. Go to your site’s dashboard.
    2. On the left sidebar, click on Snippets.
    3. Click on the Add New button.
    4. Paste your code in the box (make sure the Functions tab is selected).
    5. Click on the Save Changes and Activate button.

    Let me know if you need further help.

    Thread Starter ripriprip


    Thank you, I do need further help, I don’t understand where to put the 0 ? as in this comment.

    // return 0; set cookie to expire at the end of the session

    could someone paste the code, exactly how I am to paste it into my code snippets, please?

    Thank you so much.

    Prin a11n


    Hi @ripriprip,

    You will need to replace the line return time() + 600 ; with return 0;, so:

    function Modif_expir_cookie( $time ) { 
      return 0;
    add_filter('post_password_expires', 'Modif_expir_cookie' );

    Hope this helps.

    Thread Starter ripriprip


    Thank you.

    Moderator Jan Dembowski


    Forum Moderator and Brute Squad

    @ripriprip I’m sorry but this topic is being closed. Here’s why.

    You wrote this. It’s archived now but moderators can still see it.

    do you do small paid code modification projects? I might need some help, for functionality above my abilities. [email redacted ] -I hope you don’t mind me asking.

    Per the forum guideline I am now closing this topic.

    If you need to hire someone please consider posting to instead.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘post_password_expires’ is closed to new replies.