Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
695 views
in Technique[技术] by (71.8m points)

wordpress - wp-login.php redirection - disable WooCommerce redirection to My Account

We've a WoordPress with WooCommerce (which we are not using at the moment, but don't want to get rid of), and when users sign up and follow the set up password instructions, they end up in oursite.com/wp-login.php.

The problem comes when they log in, because they're automatically redirected to WooComerce's My Account page. We would like to take users to a different page.

Is it possible to disable this WooCommerce functionality? Choose a different page or even go to the homepage instead?

Thanks!

question from:https://stackoverflow.com/questions/65850792/wp-login-php-redirection-disable-woocommerce-redirection-to-my-account

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

WooCommerce uses this filter to force redirect customers to my-account page woocommerce_prevent_admin_access, so you need to pass false to this filter to disable the woocommerce redirect

add_action(
    'admin_init',
    function() {
        add_filter( 'woocommerce_prevent_admin_access', '__return_false', 100 );
    },
    1
);

You can then use login_redirect filter after that to customize the wordpress redirect link after login


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...