[英]Wordpress login page redirecting to Woocommerce My-Account Page for Normal Users
I am in a deep trouble. 我很麻烦。 Please help me to find a solution for the following.
请帮助我找到以下解决方案。
I have wordpress site which uses Woocommerce Plugin. 我有使用Woocommerce插件的wordpress网站。 Normally Woocommerce doesn't allow normal Users (Customer,User - These are roles that you can Select from Wordpress Admin Area > Add new User > Role).
通常,Woocommerce不允许普通用户使用(客户,用户-这些角色,您可以从“ WordPress管理区域”>“添加新用户”>“角色”中选择)。 The problem is that only Administrator(Role) privilege guys have the access to see the Admin area dashboard and full settings.
问题在于只有Administrator(Role)特权人员有权查看Admin区域的仪表板和完整设置。
I need all users to enter into dashboard area without redirecting to my-account page . 我需要所有用户进入仪表板区域而不重定向到“我的帐户”页面。 Because now when users with Role Customer or something like, tried to enter login credentials of admin, they are getting redirected to my-account page.
因为现在当具有Role Customer或类似角色的用户尝试输入admin的登录凭据时,他们将被重定向到“我的帐户”页面。 Only Administrator privilege role has the capability of entering the dashboard and settings.
只有管理员特权角色才能输入仪表板和设置。
So I searched in google and found the following link: 所以我在谷歌搜索,发现以下链接:
WooCommerce admin bar and dashboard access - Role editor page link WooCommerce管理栏和仪表板访问-角色编辑器页面链接
I tried the following link by writing the following code in functions.php , but now I can't see admin settings, please see the screenshot that I can see when entering as a normal user. 我通过在functions.php中编写以下代码来尝试以下链接,但现在看不到管理设置,请查看以普通用户身份登录时可以看到的屏幕截图。
I need all users access to see admin area dashboard and admin area settings (able to see Post, Page, Settings etc) and donot want to redirect to my-account page. 我需要所有用户访问权限来查看管理区域仪表板和管理区域设置(可以查看帖子,页面,设置等),并且不想重定向到我的帐户页面。
please help to find a solution for this, since I am struggling with this for a long time. 请帮忙寻找解决方案,因为我已经为此苦苦挣扎了很长时间。
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. 我花了很多时间寻找这个问题的答案,可以在prevent_admin_access函数下的class-wc-admin.php文件中找到它。
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. 对于您的函数PHP文件,它将阻止它阻止没有以下内容的用户:'edit_posts','manage_woocommerce','view_admin_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. 可能还有另一个插件将用户重定向到WooCommerce 我的帐户页面。
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: 正如LauraTheExplorer所说,请使用以下过滤器:
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');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.