我怎么能告诉这段代码重定向到我想要的URL?

时间:2018-06-03 08:14:48

标签: php wordpress redirect woocommerce

我想告诉这部分代码在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;
}

1 个答案:

答案 0 :(得分:0)

尝试使用以下代码。请将此代码放在活动主题的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);