• Resolved marcorroma

    (@marcorroma)


    Hello,
    Is it possible to set a deadline of 15 minutes (after access)?
    How can I do by changing the code?
    Thank you

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi marcorroma,

    in your functions.php (in your theme) you can add sth like this:

    add_filter( 'tlwp_expiry_options', 'my_tlwp_expiry_option', 10, 1);
    
    function my_tlwp_expiry_option( $options ) {
    
        $options['15_minutes_after_access'] = array(
    
            'label' => __('15 Minutes after Access', 'text-domain'),
        	'group' => 'after_access',
        	'group_name' => __( 'After Access', 'temporary-login-without-password' ),
        	'expiry_label' => __( '15 Minutes after access', 'text-domain' ),
            'timestamp' => MINUTE_IN_SECONDS * 15 ,
            'order' => 1 // dropdown options will be sort with this number
    
        );
    }

    Just be aware, that the time the user is in the system is only checked, when there is a change of the page/post the user is on.
    If the user is on one page, just reading it or watching a video on that page, they can do that for hours, because the page does not check the permission for the user “automatically”.

    Good luck!

    • This reply was modified 4 years, 4 months ago by emanaku.
    Thread Starter marcorroma

    (@marcorroma)

    Thanks for the quick reply.
    If I insert that code into the theme functions, I will display the settings of your plugin screenshot:
    https://i.ibb.co/wrHHXCX/Schermata-2020-07-13-alle-18-41-22.png

    Ok, sorry. I forgot the “return $options” at the end. Here is the correct version:

    add_filter( 'tlwp_expiry_options', 'my_tlwp_expiry_option', 10, 1);
    
    function my_tlwp_expiry_option( $options ) {
    
        $options['15_minutes_after_access'] = array(
    
            'label' => __('15 Minutes after Access', 'text-domain'),
        	'group' => 'after_access',
        	'group_name' => __( 'After Access', 'temporary-login-without-password' ),
        	'expiry_label' => __( '15 Minutes after access', 'text-domain' ),
            'timestamp' => MINUTE_IN_SECONDS * 15 ,
            'order' => 1 // dropdown options will be sort with this number
    
        );
        return $options;
    }

    Good luck!

    Thread Starter marcorroma

    (@marcorroma)

    Thank you! 5 stars!

    Thread Starter marcorroma

    (@marcorroma)

    Hi, it seemed to work, in reality it is not set 15 minutes but 24h.
    Why?

    How can you see the 24 hours?

    Thread Starter marcorroma

    (@marcorroma)

    I have text staying 15 minutes on the page, updating the page and the login was still active.
    And also here:
    https://i.ibb.co/7t2HNp3/Schermata-2020-07-13-alle-19-37-50.png

    (1) make sure you have the line
    'timestamp' => MINUTE_IN_SECONDS * 15 ;
    right in your functions.php
    (2) reload your page with the Temporary Logins
    (3) make a new Temporary Login – choose the 15 minutes after access
    (4) should work ??
    Worked for me in many cases….

    Thread Starter marcorroma

    (@marcorroma)

    I had made a wrong step.
    It works very well. Thank you!

    @emanaku Appreciate your help to @marcorroma

    That’s the power of the community where people are helping each other.

    • This reply was modified 4 years, 4 months ago by Malay Ladu. Reason: update message
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Different deadline’ is closed to new replies.