Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/4b20e1f82f27f136c4d4aba269c02b37 to your computer and use it in GitHub Desktop.
Save andrewlimaza/4b20e1f82f27f136c4d4aba269c02b37 to your computer and use it in GitHub Desktop.
Redirect non approved members from their account Page ( Paid Memberships Pro )
<?php
/**
* Redirect non-approved members from the Membership Account Page for Paid Memberships Pro.
* Requires PMPro Approvals Add On to be installed - https://www.paidmembershipspro.com/add-ons/approval-process-membership/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function my_redirect_non_approved_members(){
global $current_user;
$level_id = $current_user->membership_level->ID;
$approval_status = get_user_meta( $current_user->ID, 'pmpro_approval_' . $level_id, true );
if( is_page( array( 'membership-account', 'your-profile' ) ) && ( !empty( $approval_status ) && 'approved' != $approval_status['status'] ) ) {
wp_redirect( home_url() );
die;
}
}
add_action( 'template_redirect', 'my_redirect_non_approved_members' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment