1. Home
  2. Knowledge Base
  3. WooCommerce Members Only
  4. Registration
  5. Set a fixed expiry date
  1. Home
  2. Knowledge Base
  3. WooCommerce Members Only
  4. Set a fixed expiry date

Set a fixed expiry date

By default, you can set expiry dates a specific period of time into the future. So a membership role will expire one month, one year, etc from the time of purchase.

If you’d prefer to set a specific date, you’d need to use the following filter:

<?php
/**
* Set fixed expiry date
*/
function prefix_role_expiration_date( $expires, $role, $user_id ) {
$expires = '25 October 2020';
return strtotime( $expires );
}
add_filter( 'wcmo_role_expiration_date', 'prefix_role_expiration_date', 10, 3 );

Here’s how to add a snippet.

Was this article helpful?

Related Articles