Skip to content

Commit

Permalink
Fix warning in admin
Browse files Browse the repository at this point in the history
* Fixes an issue in the admin when the $pmpro_membership_card_user is empty.
  • Loading branch information
andrewlimaza committed Oct 19, 2022
1 parent 44795c3 commit 4bd7ea9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pmpro-membership-card.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ function pmpro_membership_card_return_user_name( $pmpro_membership_card_user ){
* Returns the members most distant expiration date for their memberships.
*/
function pmpro_membership_card_return_end_date( $pmpro_membership_card_user ){

// Make sure the user exists.
if ( empty( $pmpro_membership_card_user ) ) {
return __( 'Never', 'pmpro-membership-card' );
}

$furthest_enddate = null;
foreach ( $pmpro_membership_card_user->membership_levels as $level ) {
if ( $furthest_enddate == null || $level->enddate > $furthest_enddate ) {
Expand All @@ -333,6 +339,12 @@ function pmpro_membership_card_return_end_date( $pmpro_membership_card_user ){
* @param object $pmpro_membership_card_user The membership user.
*/
function pmpro_membership_card_output_levels_for_user( $pmpro_membership_card_user ) {

// Make sure the user exists.
if ( empty( $pmpro_membership_car_user ) ) {
return esc_html_e( 'None', 'pmpro-membership-card' );
}

// Get the user's current levels.
$levels = $pmpro_membership_card_user->membership_levels;
if ( empty( $levels ) ) {
Expand Down

0 comments on commit 4bd7ea9

Please sign in to comment.