Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Last active July 20, 2022 07:55
Show Gist options
  • Save patrickposner/f7f3cbb1f55e7869657d7ccfb4ad8177 to your computer and use it in GitHub Desktop.
Save patrickposner/f7f3cbb1f55e7869657d7ccfb4ad8177 to your computer and use it in GitHub Desktop.
Filr: Send e-mail before file expires.
<?php
add_action( 'filr_before_check_expire_date', function( $expiration_date, $today ) {
$difference = $expiration_date->diff( $today );
// Get difference in days.
if ( $difference->d <= 2 ) {
// prepare and send the e-mail.
$to = 'you@company.com';
$subject = 'File will expire in 2 days.';
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
$body = '';
// Now we can send the e-mail.
wp_mail( $to, $subject, $body, $headers );
}
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment