Created
June 19, 2024 12:23
-
-
Save JarrydLong/b82a699af961d7a136ae332164195d2e to your computer and use it in GitHub Desktop.
This file contains 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 //do not copy | |
function mypmpro_redirect_away_from_wc_endpoint(){ | |
$current_endpoint = WC()->query->get_current_endpoint(); | |
if($current_endpoint == "downloads" ) { | |
$user = wp_get_current_user(); | |
// Check if the user is logged in | |
if ( isset($user->ID) ) { | |
// If the user is a member do nothing | |
if ( ! pmpro_hasMembershipLevel() ) { | |
wp_redirect(wc_get_account_endpoint_url('dashboard')); | |
} | |
} | |
} | |
} | |
add_action('wp', 'mypmpro_redirect_away_from_wc_endpoint'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment