Skip to content

Instantly share code, notes, and snippets.

@DumahX
Created April 5, 2021 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DumahX/103d0483ca5698a0aa4b53ec80b251b2 to your computer and use it in GitHub Desktop.
Save DumahX/103d0483ca5698a0aa4b53ec80b251b2 to your computer and use it in GitHub Desktop.
<?php
function mepr_subscription_num_days() {
$user_id = get_current_user_id();
if ( 0 == $user_id ) {
return;
}
$user = new MeprUser( $user_id );
$txns = $user->active_product_subscriptions( 'transactions' );
if ( is_array( $txns ) ) {
foreach ( $txns as $txn ) {
if ( isset( $txn->product_id ) && $txn->product_id == 475 /* Change 475 to your membership's ID */ ) {
$expiration_date = $txn->expires_at; // Expiration date
}
}
}
}
add_action( 'init', 'mepr_subscription_num_days' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment