Woocommerce/Wordpress - 将用户登录重定向到主页 [英] Woocommerce/Wordpress - Redirect User Login to Homepage
本文介绍了Woocommerce/Wordpress - 将用户登录重定向到主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索了这个问题的答案,使用了插件,但仍然没有任何效果.我希望我网站的用户在登录/注册后被重定向到主页.
I have searched for the answer to this, used plugins and still nothing works. I would like users of my site to be redirected to the home page after they login/register.
目前,用户登录并被重定向到我的帐户页面.
Currently, the user logs in and is redirected to the my account page.
Woocommerce 提供了此代码,但它对我不起作用:
Woocommerce provides this code, but it failed to work for me:
/*
* goes in theme functions.php or a custom plugin
*
* By default login goes to my account
**/
add_filter('woocommerce_login_widget_redirect', 'custom_login_redirect');
function custom_login_redirect( $redirect_to ) {
$redirect_to = 'http://anypage.com';
}
我也尝试过使用 Peter's Redirect 插件,但由于 woocommerce 绕过了 wp-login.php,它不起作用.
I have also attempted to use the Peter's Redirect plugin but it does not work since woocommerce bypasses wp-login.php.
想法?
推荐答案
在functions.php上使用这段代码
Use this code on functions.php
add_filter('woocommerce_login_redirect', 'wc_login_redirect');
function wc_login_redirect( $redirect_to ) {
$redirect_to = 'https://www.google.co.in/';
return $redirect_to;
}
这篇关于Woocommerce/Wordpress - 将用户登录重定向到主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文