Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created August 25, 2017 09:32
Show Gist options
  • Save andrewlimaza/d3c55a247652fb53066c43a9efedc4a7 to your computer and use it in GitHub Desktop.
Save andrewlimaza/d3c55a247652fb53066c43a9efedc4a7 to your computer and use it in GitHub Desktop.
Check if a Paid Memberships Pro user is pending or denied.
<?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