Wordpress login page redirecting to Woocommerce My-Account Page for Normal Users

人盡茶涼 提交于 2019-12-04 16:26:43

I spent a lot of time looking for the answer to this one and it can be found in the class-wc-admin.php file under the prevent_admin_access function.

Add the following code:

add_filter( 'woocommerce_prevent_admin_access', '__return_false' );

To your functions PHP file and it will stop it blocking users who do not have: 'edit_posts', 'manage_woocommerce', 'view_admin_dashboard' from accessing the dashboard.

For good measure you can also add this which overrides the account permalink to be your admin page - which may be relevant.

function my_account_permalink($permalink) {

    return admin_url();
}

add_filter( 'woocommerce_get_myaccount_page_permalink', 'my_account_permalink', 1); 

There might be another plugin redirecting a user to the WooCommerce, My Account Page.

In the case of the Formidable Forms plug in along with the Formidable Registration plug in, this can happen if the Login/Logout Page is set to the My Account Page. This setting can be found at Formidable, Global Settings, Registration and under Global Pages change the Login/Logout - click the drop list and scroll to the blank line at the top of this list.

However in your case you might have a different plug in doing something similar.

As LauraTheExplorer said, use this filter:

add_filter( 'woocommerce_prevent_admin_access', '__return_false' );

Use this filter to also enable the Admin Bar:

add_filter('woocommerce_disable_admin_bar', '__return_false');

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!