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

时间:2018-03-17 02:04:24

标签: wordpress woocommerce hook-woocommerce custom-wordpress-pages

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

// Add a custom Order Manager

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

我可以在管理面板中指定此角色,此人接受邀请,但当他们登录时,会将其重定向到网站的目标网页(' /'路线) !我从https://www.role-editor.com/woocommerce-view-edit-orders/获取$ power并避免使用任何插件:)我从该链接中删除了#34; Orders"它们列出了所有订单类型,并直接从中创建了我的自定义用户。我也是以隐身模式完成此操作,删除了用户并重新添加,并通过管理面板将用户从任何现有会话中记录下来。

编辑我已在两个电子邮件地址中确认了此行为。新用户和更改当前用户的角色。我还添加了阅读' => '真正的'也是这个角色。仍然将302带到商店的主页(不是管理员面板)

编辑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 个答案:

答案 0 :(得分:0)

如上所示,问题显然是我不理解该角色的权限。我已将它们发布在上面并希望它可以帮助那些偶然发现它的人!