如何禁用Woocommerce我的帐户Autodirect

时间:2017-04-07 02:05:10

标签: woocommerce

我想使用编辑器插件自定义Woocommerce登录/注册页面,该插件要求您登录Wordpress Dashboard。问题是,如果用户登录,Woocommerce将指向“我的帐户”页面。是否有一个我可以暂时运行的代码段,如果用户已登录,将告诉Woocommerce加载登录/注册页面而不是“我的帐户”页面? / p>

1 个答案:

答案 0 :(得分:0)

I found a solution thanks to a reply Oliver Vogel made to someone else asking the same question here. Thanks Oliver! This is Oliver's Post

For non-technical people like me who are trying to edit the Woocommerce Login / Register page while being logged into the Wordpress dashboard, insert this snippet into the functions.php file preferably with a nice plugin like Code Snippets. It will create a shortcode called [woo-login]. Create a new web page and add the [woo-login] shortcode to it and the Woo login page will open even when you are logged in.

add_shortcode('woo-login', 'my_login');

function my_login() {
    if (is_user_logged_in()) {
     ob_start();
        echo '<div class="woocommerce">';
        wc_get_template('myaccount/form-login.php');
        echo '</div>';
        return ob_get_clean();
    } else {
        ob_start();
        echo '<div class="woocommerce">';
        wc_get_template('myaccount/form-login.php');
        echo '</div>';
        return ob_get_clean();
    }
}
相关问题