id ) { // Redirect user to the account page if no invoice found. wp_redirect( pmpro_url( 'account' ) ); exit; } // Make sure they have permission to view this. if ( ! current_user_can( 'pmpro_orders' ) && $current_user->ID != $pmpro_invoice->user_id ) { wp_redirect( pmpro_url( 'account' ) ); //no permission exit; } }