Created
April 5, 2021 12:47
-
-
Save DumahX/103d0483ca5698a0aa4b53ec80b251b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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