Skip to content

Instantly share code, notes, and snippets.

@SeanTOSCD
Created June 29, 2017 14:28
Show Gist options
  • Save SeanTOSCD/b77f3c3ad36e3e80411008461c27596a to your computer and use it in GitHub Desktop.
Save SeanTOSCD/b77f3c3ad36e3e80411008461c27596a to your computer and use it in GitHub Desktop.
EDD SL get expired licenses
<?php
// check for expired licenses
$license_args = array(
'posts_per_page' => -1,
'post_type' => 'edd_license',
'post_status' => 'any',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_edd_sl_user_id',
'value' => get_current_user_id(),
'compare' => '='
),
array(
'relation' => 'AND',
array(
'key' => '_edd_sl_status',
'value' => 'expired',
'compare' => '='
),
array(
'key' => '_edd_sl_expiration',
'value' => time(),
'compare' => '<'
)
),
),
);
$license_keys = get_posts( $license_args );
// how many expired licenses are there?
$expired_qty = count( $license_keys );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment