注册后 Woocommerce 重定向 [英] Woocommerce redirect after registration

查看:35
本文介绍了注册后 Woocommerce 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Woocommerce 注册后重定向用户.我已经尝试了一切,但它不起作用.

I am trying to redirect user after Woocommerce registration. I have tried everything and it is not working.

我尝试了一些在互联网上找到的方法,但它们不起作用......

I have tried some methods found on internet but they didn't work…

当我将myaccount"更改为另一个永久链接时,它会在您单击注册时冻结.. 不知道为什么.

When I change 'myaccount' to another permalink it just freezes when you click register.. not sure why.

wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'welcome' ) ) 

我什至尝试使用页面 ID

I even tried with the page id

wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( '1072' ) ) 

有什么帮助吗?

推荐答案

接受的答案对我不起作用.对我有用的是:

The accepted answer didn’t work for me. What worked for me was this:

// After registration, logout the user and redirect to home page
function custom_registration_redirect() {
    wp_logout();
    return home_url('/');
}
add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);

这篇关于注册后 Woocommerce 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆