Created
August 25, 2017 09:32
-
-
Save andrewlimaza/d3c55a247652fb53066c43a9efedc4a7 to your computer and use it in GitHub Desktop.
Check if a Paid Memberships Pro user is pending or denied.
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 | |
//General code example for checking if a current user is pending or not. | |
global $current_user; | |
//check to see if the user has any membership level | |
if( pmpro_hasMembershipLevel() ) { | |
// Get the current user ID and their level ID for the PMPro Approvals meta. | |
$user_id = $current_user->ID; | |
$level = pmpro_getMembershipLevelForUser( $user_id ); | |
$level_id = $level->id; | |
//get the user meta. | |
$approval_status = get_user_meta( $user_id, 'pmpro_approval_'.$level_id, true ); | |
//check the user meta. | |
if( $approval_status['status'] !== 'pending' || $approval_status['status'] !== 'denied' ){ | |
//show content here, assume they are approved or don't require approval if the user doesn't have pending or denied. | |
}else{ | |
//show a restricted message for users. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment