【问题标题】:How can i tell this code to redirect to the URL I want?我如何告诉此代码重定向到我想要的 URL?
【发布时间】:2018-06-03 08:14:47
【问题描述】:

我想告诉这部分代码在 woocommerce 注册 (wordpress) 后转到我想要的 URL。它是开源插件的一部分。我知道重定向应该发生在这里,但我不知道如何告诉它去注册成功页面。 Woocommerce 注册后进入主页。

/*
 * This function is executed just after a new user is made from woocommerce registration form in myaccount page.
 * Its hooked into 'woocommerce_registration_redirect' filter.
 * If restrict user setting is enabled from the plugin settings screen, then this function will logs out the user.
 */

public function redirect_new_user($redirect) 
{
    if ($this->is_new_user_email_sent 
        && !XlWUEV_Common::$is_xlwuev_resend_link_clicked
        && !defined('WC_DOING_AJAX') 
        && !is_order_received_page()) 
    {
        $redirect = add_query_arg(array('xlrm' => base64_encode($this->user_id), ), $redirect);
        $is_xlwuev_restrict_user = XlWUEV_Common::get_setting_value('wuev-general-settings', 'xlwuev_restrict_user');

        if ('1' == $is_xlwuev_restrict_user) 
            wp_logout();
    }
    return $redirect;
}

【问题讨论】:

    标签: php wordpress redirect woocommerce


    【解决方案1】:

    试试下面的代码。请将此代码放在您活动主题的functions.php中。

    function iconic_register_redirect( $redirect ) {
        wp_redirect(get_the_permalink(2)); //// instead of 2 put the slug or id
        exit();
    }
    
    add_filter( 'woocommerce_registration_redirect', 'iconic_register_redirect' ,99,1);
    

    【讨论】:

    • 它仍然重定向到主页
    • 优先尝试我更新了代码,如果它仍然不起作用,你能告诉我你的系统中还有哪些其他插件
    • 谢谢。我将它放入主题的 functions.php 现在我得到错误 500 。 xxxxx.com 目前无法处理此请求。 HTTP 错误 500
    • 现在检查一下,我这边有一些语法错误
    • 它又回到了主页。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-02
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多