Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created November 6, 2020 23:17
Show Gist options
  • Save ronalfy/116f5b7a5d1d908731d21fd48ac06c6e to your computer and use it in GitHub Desktop.
Save ronalfy/116f5b7a5d1d908731d21fd48ac06c6e to your computer and use it in GitHub Desktop.
PMPro - Allow Pending Check Members Access to Restricted Content
<?php
/**
* Allow pay-by-check pending access to full site.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpropbc_pmpro_has_membership_access_filter( $hasaccess, $post, $user, $post_membership_levels ) {
if ( ! is_user_logged_in() ) {
return $hasaccess;
}
// If status is already true, return.
if ( $hasaccess ) {
return $hasaccess;
}
if ( ! class_exists( 'MemberOrder' ) ) {
return $hasaccess;
}
global $current_user;
// Retrieve order.
$member_order = new MemberOrder();
$order = $member_order->getLastMemberOrder( $current_user->ID, 'pending', null, 'check' );
if ( false === $order ) {
return $hasaccess;
} else {
return true;
}
return $hasaccess;
}
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpropbc_pmpro_has_membership_access_filter', 15, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment