当前位置: 首页 > 知识库问答 >
问题:

Woocommerce自定义角色重定向到商店登录页

蒋联
2023-03-14

嘿,伙计们,我创建了一个非常简单的“订单经理”角色,应该只能查看和编辑订单。代码如下:

// Add a custom Order Manager

add_role(
    'order_manager',
    __( 'Order Manager' ),
    array(
        'read_shop_order'   => true,  
        'edit_shop_order'   => true,
    )
);

我可以在管理面板中分配此角色,此人接受邀请,但当他们登录时,它会将他们重定向到站点的登录页(“/”路径)!我从你那里拿走了$capabilitieshttps://www.role-editor.com/woocommerce-view-edit-orders/并避免使用任何插件:)我从“订单”链接中放大了图片,他们列出了所有订单类型,并直接从中创建了我的自定义用户。我也在匿名模式下完成了这项工作,删除了用户并重新添加了他们,并通过管理面板将用户从任何现有会话中注销。

编辑我已在两个电子邮件地址中确认此行为。新用户和正在更改的当前用户角色。我还加了“阅读”=

编辑2看起来这些是错误的$功能,无法让他们访问管理面板中的订单。我刚被赋予查看自己未结订单的能力。。。。有人知道让他们在管理栏中查看订单的正确功能吗?:)

编辑3我运行了以下内容来将用户功能管道到管理员的屏幕上

$data = get_userdata( get_current_user_id() );

if ( is_object( $data) ) {
    $current_user_caps = $data->allcaps;

    // print it to the screen
    echo '<pre>' . print_r( $current_user_caps, true ) . '</pre>';
}

因此,这吐出了所有的管理角色的WooCommerce。我现在的问题是你如何更容易地获得这些数据?有没有像WP这样的终端可以响应?这是超级丑陋的,在我的管理页面(然后更新functions.php)又不见了。你怎么能在那里最小化周期?

未来,woocommerce中的所有管理员权限为:

Array
(
    [switch_themes] =>; 1
    [edit_themes] =>; 1
    [activate_plugins] =>; 1
    [edit_plugins] =>; 1
    [edit_users] =>; 1
    [edit_files] =>; 1
    [manage_options] =>; 1
    [moderate_comments] =>; 1
    [manage_categories] =>; 1
    [manage_links] =>; 1
    [upload_files] =>; 1
    [import] =>; 1
    [unfiltered_html] =>; 1
    [edit_posts] =>; 1
    [edit_others_posts] =>; 1
    [edit_published_posts] =>; 1
    [publish_posts] =>; 1
    [edit_pages] =>; 1
    [read] =>; 1
    [level_10] =>; 1
    [level_9] =>; 1
    [level_8] =>; 1
    [level_7] =>; 1
    [level_6] =>; 1
    [level_5] =>; 1
    [level_4] =>; 1
    [level_3] =>; 1
    [level_2] =>; 1
    [level_1] =>; 1
    [level_0] =>; 1
    [edit_others_pages] =>; 1
    [edit_published_pages] =>; 1
    [publish_pages] =>; 1
    [delete_pages] =>; 1
    [delete_others_pages] =>; 1
    [delete_published_pages] =>; 1
    [delete_posts] =>; 1
    [delete_others_posts] =>; 1
    [delete_published_posts] =>; 1
    [delete_private_posts] =>; 1
    [edit_private_posts] =>; 1
    [read_private_posts] =>; 1
    [delete_private_pages] =>; 1
    [edit_private_pages] =>; 1
    [read_private_pages] =>; 1
    [delete_users] =>; 1
    [create_users] =>; 1
    [unfiltered_upload] =>; 1
    [edit_dashboard] =>; 1
    [update_plugins] =>; 1
    [delete_plugins] =>; 1
    [install_plugins] =>; 1
    [update_themes] =>; 1
    [install_themes] =>; 1
    [update_core] =>; 1
    [list_users] =>; 1
    [remove_users] =>; 1
    [promote_users] =>; 1
    [edit_theme_options] =>; 1
    [delete_themes] =>; 1
    [export] =>; 1
    [manage_woocommerce] =>; 1
    [view_woocommerce_reports] =>; 1
    [edit_product] =>; 1
    [read_product] =>; 1
    [delete_product] =>; 1
    [edit_products] =>; 1
    [edit_others_products] =>; 1
    [publish_products] =>; 1
    [read_private_products] =>; 1
    [delete_products] =>; 1
    [delete_private_products] =>; 1
    [delete_published_products] =>; 1
    [delete_others_products] =>; 1
    [edit_private_products] =>; 1
    [edit_published_products] =>; 1
    [manage_product_terms] =>; 1
    [edit_product_terms] =>; 1
    [delete_product_terms] =>; 1
    [assign_product_terms] =>; 1
    [edit_shop_order] =>; 1
    [read_shop_order] =>; 1
    [delete_shop_order] =>; 1
    [edit_shop_orders] =>; 1
    [edit_others_shop_orders] =>; 1
    [publish_shop_orders] =>; 1
    [read_private_shop_orders] =>; 1
    [delete_shop_orders] =>; 1
    [delete_private_shop_orders] =>; 1
    [delete_published_shop_orders] =>; 1
    [delete_others_shop_orders] =>; 1
    [edit_private_shop_orders] =>; 1
    [edit_published_shop_orders] =>; 1
    [manage_shop_order_terms] =>; 1
    [edit_shop_order_terms] =>; 1
    [delete_shop_order_terms] =>; 1
    [assign_shop_order_terms] =>; 1
    [edit_shop_coupon] =>; 1
    [read_shop_coupon] =>; 1
    [delete_shop_coupon] =>; 1
    [edit_shop_coupons] =>; 1
    [edit_others_shop_coupons] =>; 1
    [publish_shop_coupons] =>; 1
    [read_private_shop_coupons] =>; 1
    [delete_shop_coupons] =>; 1
    [delete_private_shop_coupons] =>; 1
    [delete_published_shop_coupons] =>; 1
    [delete_others_shop_coupons] =>; 1
    [edit_private_shop_coupons] =>; 1
    [edit_published_shop_coupons] =>; 1
    [manage_shop_coupon_terms] =>; 1
    [edit_shop_coupon_terms] =>; 1
    [delete_shop_coupon_terms] =>; 1
    [assign_shop_coupon_terms] =>; 1
    [administrator] =>; 1
)

共有1个答案

上官鸿朗
2023-03-14

如上所示,问题显然是我不理解角色的权限。我已经把它们贴在上面了,希望它能帮助下一个偶然发现这个的人!

 类似资料:
  • 问题内容: 我正在使用Laravel Framework 5.4.10,并且正在使用常规身份验证 提供。我想保护整个应用程序,并在登录后将用户重定向到/ themes。 我有4个控制器:ForgotPasswordController.php,LoginController.php,RegisterController.php和ResetPasswordController.php。我已经将此行编

  • 我使用jsf servlet并创建了自定义登录页面,使用了带有动作j_spring_security_check的表单,方法POST,使用了j_username和j_password。当我单击登录按钮时,我遇到的问题不是重定向到页面,而是在Chrome网络列中显示了带有302状态代码的post方法j_spring_security_check,我是否使用了Spring安全的正确方式? 登录。jsf

  • 我正在将DNN应用程序从07.00.02升级到07.03.04并在安装后将所有门户重定向到登录页面。所有门户都配置有一个登陆页面,该页面被配置为允许“所有用户”角色视图访问。还有人在升级后遇到过这个问题吗? 2015-02-05 05:45:01 127.0.0.1 GET/-80-127.0.0.1 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/

  • 记录器文件中的日志- org.springframework.Security.Access.event.loggerlistener-安全授权失败,原因是:org.springframework.Security.Access.accessdeniedexception:访问被拒绝;通过身份验证的主体:org.springframework.security.authentication.ano

  • 问题内容: 我有一个网站,有一个用户系统。我想将wordpress的用户系统集成到该网站的系统中,但是我仍然想使用该网站的注册/登录页面。我不希望任何人都能使用Wordpress的登录或注册表格进行登录或注册。相反,当他们尝试访问Wordpress中的登录/注册页面时,我希望这些页面将它们重定向到我自己的登录/注册页面。 有什么办法吗?我已经尝试过Google,但是我所能找到的只是在用户登录或注册

  • 我使用谷歌商店定位器(http://storelocator.googlecode.com/git/examples/custom.html)显示体育赛事。 现在我想自定义来自谷歌的消息。我想隐藏信息“这个地区没有商店。然而,离你最近的商店列在下面。"如果缩放区域中没有事件。我想在面板中的孔线上放一个链接,以重定向到特定的网址。 是否有任何选项可以根据我的愿望定制商店定位器? 谢谢