Change WordPress user roles and capabilities › Forums › How to or FAQ › Restrict special Woocommerce report (tabs)
- This topic has 5 replies, 2 voices, and was last updated 6 years, 9 months ago by
[email protected].
-
AuthorPosts
-
07/03/2019 at 21:10 #5552
[email protected]
ParticipantHi Vladimir,
where can we restrict special woocommerce reports (tabs) ?for example:
should be ALLOWED
https://demo.com/wp-admin/admin.php?page=wc-reports&tab=gift_certsshould be NOT allowed
https://demo.com/wp-admin/admin.php?page=wc-reports&tab=customers&report=customer_listThanks & Regards
Dieter09/03/2019 at 05:57 #5560[email protected]
ParticipantHi Vladimir,
can we restrict/handle special URL’s with user role editor?Thanks & Regards
Dieter09/03/2019 at 15:12 #5561Vladimir
KeymasterHi Dieter,
URE does not include functionality for editing the list of WooCommerce reports available to user.
WooCommerce itself offers to use special filter for this purpose:$reports = apply_filters( 'woocommerce_admin_reports', $reports );Thus it’s possible to hook a function to this filter and remove from the list prohibited reports.
You can not restrict special URL(s) with User Role Editor. Custom code is needed also.
09/03/2019 at 15:32 #5562[email protected]
ParticipantHi Vladimir,
thank you for feedback and support!For first quick solution we have made this …
add_filter( ‘woocommerce_admin_reports’, ‘custom_reports’ );
function custom_reports( $reports ) {
// unset the elements of $reports that you don’t want
unset($reports[‘customers’]);
unset($reports[‘stock’]);
unset($reports[‘orders’]);
unset($reports[‘taxes’]);
return $reports;
}In second step we must see how we can make report access for admins.
Thanks & Regards
Dieter10/03/2019 at 01:54 #5563Vladimir
KeymasterHi Dieter,
You can define admin by few different ways. Select the most suitable for you.
Insert selected code before the 1st unset(…);if ( current_user_can( 'manage_woocommerce' ) ) { // WooCommerce admin return; }if ( is_super_admin() ) { // WordPress super admin - real super admin for network, but just user with 'delete_users' capability for single site installation return; }$lib = URE_Lib::get_instance(); if ( $lib->is_super_admin() ) { // user with 'administrator' role for single site installation and real super admin for network return; }10/03/2019 at 10:42 #5564[email protected]
ParticipantHi Vladimir,
yes that’s works!Thanks for your great support!!!
Thanks & Regards
Dieter -
AuthorPosts
- You must be logged in to reply to this topic.