Last active
August 29, 2015 14:20
-
-
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
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 | |
//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