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的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屋!
查看全文