Last active
February 19, 2019 23:25
-
-
Save andrewlimaza/4b20e1f82f27f136c4d4aba269c02b37 to your computer and use it in GitHub Desktop.
Redirect non approved members from their account Page ( Paid Memberships Pro )
This file contains hidden or 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 | |
/** | |
* 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