Skip to content

Instantly share code, notes, and snippets.

@LMNTL
Forked from andrewlimaza/pay-by-check-no-access.php
Last active July 26, 2019 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LMNTL/9e3fe4a8a6485904992c4525517cd016 to your computer and use it in GitHub Desktop.
Save LMNTL/9e3fe4a8a6485904992c4525517cd016 to your computer and use it in GitHub Desktop.
Force users with pending orders from Pay By Check Add On and PMPro to not have access to any member content.
<?php
/**
* This checks to see if the user has a 'pending' check order and will deny access whever member content is called.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) {
$order = new MemberOrder();
$order->getLastMemberOrder( $user->ID, array( 'pending', '', 'check' ) );
// if there are any pending orders done by check, restrict access.
if ( ! empty( $order->status ) ) {
$hasaccess = false;
}
return $hasaccess;
}
add_filter( 'pmpro_has_membership_access_filter', 'pmpro_deny_if_user_is_pending', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment