Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Created February 23, 2024 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuriinalivaiko/2d3d15a49aba9f8ef5758c0ffc7b157f to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/2d3d15a49aba9f8ef5758c0ffc7b157f to your computer and use it in GitHub Desktop.
WooCommerce redirects
<?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 );
<?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