Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
Last active August 29, 2015 14:20
Show Gist options
  • Save WillBrubaker/40a8da1269ba8657dd6a to your computer and use it in GitHub Desktop.
Save WillBrubaker/40a8da1269ba8657dd6a to your computer and use it in GitHub Desktop.
redirects WooCommerce my account page to the default WordPress login if user is not logged in
<?php
//don't include the opening PHP tag
add_action( 'template_redirect', 'handsomebeardedguy_redirect_myaccount' );
function handsomebeardedguy_redirect_myaccount() {
if ( function_exists( 'is_account_page' ) && is_account_page() && ! is_user_logged_in() ) {
wp_redirect( wp_login_url( get_permalink( wc_get_page_id( 'shop' ) ) ) );
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment