Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Created June 19, 2024 12:23
Show Gist options
  • Save JarrydLong/b82a699af961d7a136ae332164195d2e to your computer and use it in GitHub Desktop.
Save JarrydLong/b82a699af961d7a136ae332164195d2e to your computer and use it in GitHub Desktop.
<?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