Created
February 23, 2024 19:03
-
-
Save yuriinalivaiko/2d3d15a49aba9f8ef5758c0ffc7b157f to your computer and use it in GitHub Desktop.
WooCommerce redirects
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 | |
// Change the default WooCommerce login redirect URL. | |
function um_woocommerce_login_redirect( $redirect, $user ) { | |
if ( function_exists( 'um_get_core_page' ) ) { | |
$redirect = um_get_core_page( 'account' ); | |
} | |
return $redirect; | |
} | |
add_filter( 'woocommerce_login_redirect', 'um_woocommerce_login_redirect', 10, 2 ); |
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 | |
// Redirect from the WooCommerce "My account" page to the Ultimate Member "Account" page. | |
function um_woocommerce_myaccount_redirect() { | |
global $wp_query; | |
if ( $wp_query->is_singular( 'page' ) ) { | |
$queried_page = $wp_query->get_queried_object(); | |
$myaccount_page_id = (int) get_option( 'woocommerce_myaccount_page_id' ); | |
if ( $queried_page->ID === $myaccount_page_id && function_exists( 'um_get_core_page' ) ) { | |
exit( wp_safe_redirect( um_get_core_page( 'account' ) ) ); | |
} | |
} | |
} | |
add_action( 'template_redirect', 'um_woocommerce_myaccount_redirect' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment