简体   繁体   English

WordPress登录页面重定向到普通用户的Woocommerce我的帐户页面

[英]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.

相关问题 结帐页面上的WooCommerce登录链接未链接到正确的页面(我的帐户) - WooCommerce login link on checkout page not linking to correct page (my-account) 将Woocommerce我的帐户页面重定向到另一个页面 - Redirect Woocommerce my-account page to another page Woocommerce-如何在单独的页面上显示订单详细信息(我的帐户) - Woocommerce - How to show Order details (my-account) on a separate page Woocommerce 如何在我的帐户页面上重定向自定义端点 - Woocommerce how to redirect a custom end point on my-account page 绕过 WooCommerce 我的帐户登录以进行自定义登录 - Bypass WooCommerce My-Account login for Custom login 为未登录用户删除 Header 和 WooCommerce My-Account 上的页脚 - Remove the Header and Footer on WooCommerce My-Account for unlogged users 如何在 Woocommerce 的单独页面上显示特定产品(id)的订单详细信息(我的帐户)? - How to show order details (my-account) for a specific product (id) on a separate page in Woocommerce? 更改我的帐户/密码丢失/页面上的Woocommerce密码丢失文本,无需覆盖模板 - Change Woocommerce Lost Password text on my-account/lost-password/ page without template override WooCommerce - 从我的帐户页面中删除国家/地区字段会阻止保存地址 - WooCommerce - removing country field from my-account page prevents from saving address 重定向用户到登录页面 - Redirecting Users to Login Page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM