Home / Archive / MemberPress: Adjusting Paywall Cookie Expiry Time
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Adjusting Paywall Cookie Expiry Time

This code snippet modifies the default expiration period (30 days) for the MemberPress paywall cookie. The code will set the cookie to expire after a specified number of days.

To set the duration of the paywall cookie, replace X with the actual number of days (whole numbers only), on this line:

$expire_time = (time() + 60 * 60 * 24 * X);

For example, replacing X with number 7 will set a one-week expiration period for the cookie.

Code Preview
php
<?php
add_filter( 'mepr-paywall-cookie-time', function( $expire_time ) {
    // Set cookie expiration time to X days (replace X with the number of days)
    $expire_time = ( time() + 60 * 60 * 24 * X ); // X represents the number of days
    return $expire_time;
});

Comments

Add a Comment