Last active
March 23, 2021 08:02
-
-
Save andrewlimaza/08d6e9d8dd647d2168774c8be46e6940 to your computer and use it in GitHub Desktop.
Revisions
-
andrewlimaza revised this gist
Mar 23, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ function my_show_user_enddate(){ $user_enddate = $current_user->membership_level->enddate; if( !$user_enddate == 0){ return 'Membership end date: ' . date_i18n('d-m-Y', $user_enddate); }else{ // See if membership is recurring. -
andrewlimaza revised this gist
Mar 23, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ function my_show_user_enddate(){ $recurring = pmpro_next_payment( $current_user->ID ); if ( $recurring) { return date_i18n( 'd-m-Y', $recurring ); } else { return 'Membership never expires.'; } -
andrewlimaza created this gist
Aug 30, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ <?php /** * Show the user's expiration date, or their next payment date. * Show the user's previously expired date if they were cancelled, expired or cancelled by an admin. * If none of thhe above is found, the string 'nothing found' will be returned. */ function my_show_user_enddate(){ if ( is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel() ){ global $current_user; $current_user->membership_level = pmpro_getMembershipLevelForUser( $current_user->ID ); $user_enddate = $current_user->membership_level->enddate; if( !$user_enddate == 0){ return 'Membership end date: ' . date('d-m-Y', $user_enddate); }else{ // See if membership is recurring. $recurring = pmpro_next_payment( $current_user->ID ); if ( $recurring) { return $recurring; } else { return 'Membership never expires.'; } } } elseif ( ! pmpro_hasMembershipLevel() ) { //try to see if they had a previous membership level. global $wpdb, $current_user; $sql = "SELECT enddate FROM $wpdb->pmpro_memberships_users WHERE `user_id` = $current_user->ID AND `status` in ('cancelled', 'expired', 'admin_cancelled') ORDER BY enddate ASC LIMIT 1"; $results = $wpdb->get_results( $sql ); if ( ! empty( $results[0] ) ) { $enddate = explode( " ", $results[0]->enddate ); return $enddate[0]; //return the date only, not time of expiration. }else{ return 'nothing found'; } } } add_shortcode( 'show_enddate', 'my_show_user_enddate' );