Whi*_*hit 5 wordpress redirect login widget woocommerce
我已经搜索了这个问题的答案,使用了插件但仍然无效.我希望我的网站用户在登录/注册后重定向到主页.
目前,用户登录并重定向到我的帐户页面.
Woocommerce提供此代码,但它无法为我工作:
/*
* 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';
}
Run Code Online (Sandbox Code Playgroud)
我也试图使用Peter的Redirect插件,但由于woocommerce绕过了wp-login.php,它无法正常工作.
思考?
小智 5
在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;
}
Run Code Online (Sandbox Code Playgroud)
他们提供的修复仅在您使用登录小部件时才有效。登录主页后重定向用户所需要做的就是将其添加到登录表单中:
<input type="hidden" name="redirect" value="<?php echo get_home_url(); ?>" />
Run Code Online (Sandbox Code Playgroud)