Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Login WordPress Dashboard
- This topic has 56 replies, 2 voices, and was last updated 8 years, 7 months ago by Vladimir.
-
AuthorPosts
-
28/02/2016 at 22:21 #2063jawadParticipant
Hi Vladimir,
Another problem as well. I am trying to edit Meta Boxes on Edit Product page.
I have selected to hide
– Product Short Description – ID ‘postexcerpt’
– Reviews – ID ‘commentsdiv’
– Product Data – ID ‘woocommerce-product-data’But these are still visible when I go to edit Product Page. Can you test on your end to see if these Meta Boxes are hiding for you?
Many Thanks,
Jawad29/02/2016 at 00:43 #2064VladimirKeymasterWhen you said ‘Edit posts restrictions’ did you mean
I meant this add-on activated and its settings made at user profile:
Notice: Undefined index: id in /wp-content/plugins/user-role-editor-pro/includes/pro/classes/meta-boxes.php on line 46
It’s not error, just notice. If you set WP_DEBUG to false at wp-config.php file, this message will not be shown.
I can not repeat this. Every meta box should have ID. URE goes through the full list of meta boxes available at this page here. So you have some strange metabox.You may help if you open includes/pro/classes/meta-boxes.php file and insert at line 39:
var_dump($wp_meta_boxes); die;
Open ‘Add Order’ page, copy output and send it to support [at-sign] role-editor.com
Then remove this debug code.if I enable ‘delete_product’ should I also enable ‘delete_products’
I wrote above that it’s not required to include meta capability like ‘delete_product’ directly to the role. It’s enough ‘delete_products’. But WooCommerce does this for its own roles, like ‘Shop Manager’. So repeat it too, include both.
29/02/2016 at 00:52 #2065VladimirKeymasterJawad,
Please ignore my ask to send me debug information about meta boxes. I found that post edit page (including one belongs to WooCommerce) may contain an empty meta box data. I will update URE’s code for this case.
29/02/2016 at 01:11 #2066VladimirKeymasterJawad,
Quick fix is open includes/pro/classes/meta-boxes.php file and replace 11 priority at lines 26,27,28 to the 99, like this
add_action('add_meta_boxes', array($this, 'remove_blocked_metaboxes'), 99); add_action('wp_dashboard_setup', array($this, 'remove_blocked_metaboxes'), 99); add_action('wp_user_dashboard_setup', array($this, 'remove_blocked_metaboxes'), 99);
As I discovered WooCommerce added its metaboxes with 20 and 30 priorities. So we should use higher priority to remove them later than they were added.
29/02/2016 at 19:52 #2069jawadParticipantHi Vladimir,
Thanks for the quick fix. I have added this and now Meta Boxes are being hidden properly. I thought this was code to fix the error which is why I mistakenly emailed you the debug code. Hope it may be of use.
Couple of things I’d like to clear up:-
1) On the WooCommerce ‘Products’ page, I am trying to get the products list on this page as read only. So cannot ‘Edit’ or ‘Duplicate’ product. To do this, I am disabling capability, ‘edit_products’. But when I do this, the User loses access to ‘Products’ page, they are no longer able to view it. How can I make ‘Products’ view only.
2) In ‘Admin Menu’, I have disabled access to Product > Attributes. However, if I go to the link directly then this page still loads?
3) On WooCommerce > Coupons > Add Coupon page, there are Meta Box ‘Author’ & ‘Revolution Slider Options’ – but in Meta Boxes Settings page I can only see ‘Coupon Data’ as the only available Meta Box for this page?
Many Thanks,
Jawad02/03/2016 at 05:58 #2072VladimirKeymasterHi Jawad,
1) User can not see the list of products without ‘edit_products’ capability. So if you have activated with URE ‘create’ capability, giving user ‘read’, ‘edit_products’ may be enough to get a ‘read-only’ access’ to the list of products with assumption that this user did not created any product. He can not created a new product, he can not edit products created by others, he can not edit published products. Be aware that user should have at least ‘edit_posts’ or ‘manage_woocommerce’ capabilities or special filter should be set to give him access to the admin back-end.
2) I confirm the issue with ‘Products->Attributes’ access by direct link. I will investigate and fix this bug.
3) Let me know what additional plugin do you use. I installed ‘Revolution Slider’ but don’t see any additional meta box at WooCommerce Coupon edit page.
02/03/2016 at 18:32 #2075jawadParticipantHi Vladimir,
Thanks for your reply.
1) I have disabled all the options apart from the ones you mentioned and it is nearly perfect. Is there any way to prevent the user from duplicating product as well?
2) Please see the below screenshots regarding Meta Boxes:
This is the ‘Add Coupon’ page:
This is the Meta Boxes available for this page:
3) I am also seeing this PHP error on the top of every page in WordPress Dashboard:
Notice: Undefined offset: 3 in /wp-content/plugins/user-role-editor-pro/includes/pro/classes/admin-menu-access.php on line 119
Many Thanks,
Jawad04/03/2016 at 02:25 #2079VladimirKeymasterHi Jawad,
1) By default WooCommerce allows to duplicate products to the user with ‘manage_woocommerce’ capability. User without this capability does not see the ‘Duplicate’ link. I think that if user should have read-only access to the Products, then ‘manage_woocommerce’ is not required for him. So remove it from his role.
If you need to change this capability to the custom one, you may use'woocommerce_duplicate_product_capability'
filter for that.2) I do not have any meta boxes except ‘Coupon Data’ with WooCommerce and Rev. Slider only installed. I suppose you have some other active plugin, which adds sections from the screenshot to the Coupon editor page. I need to know what plugin does that.
3) Try to deactivate/activate back user role editor plugin. Open User Role Editor – ‘Admin Menu’ for that role and re-save it.
04/03/2016 at 18:18 #2085jawadParticipantHi Vladimir,
Thanks for your reply.
1) What do I do with
woocommerce_duplicate_product_capability
? Do I add this using ‘Add Capability’ and then keep it unticked to disable duplicate product?2) Unfortunately I do not see the Revolution Slider Meta Box option either? But the Author Meta Box is created by the 3rd part plugin WC Vendors – specifically WC Vendors Pro. I have emailed you a copy of the plugin. Unfortunately it does require activation and I only have one license. So I can provide you access if you need to my site? If you need any help from the developer of the plugin they are very helpful and there forum can be accessed: https://www.wcvendors.com/help/forum/wc-vendors-pro-support/
3) I have done this and it has not fixed it. The role which this notification appears on is actually created by the WC Vendors plugin, the role ‘Vendor’.
Many Thanks,
Jawad05/03/2016 at 02:56 #2087VladimirKeymasterHi Jawad,
Metaboxes:
1) I found a bug in URE Pro with WC Vendors activated. Quick fix:
open user-role-editor-pro/includes/pro/classes/meta-boxes.php
and replaceupdate_meta_boxes_list_copy()
function at line #33 with this versionpublic function update_meta_boxes_list_copy() { global $wp_meta_boxes; if (empty($wp_meta_boxes) || self::$meta_boxes_list!=null) { return; } self::$meta_boxes_list = get_option(self::META_BOXES_LIST_COPY_KEY, array()); foreach($wp_meta_boxes as $screen=>$contexts) { foreach($contexts as $context=>$priorities) { foreach($priorities as $priority=>$meta_boxes) { foreach($meta_boxes as $meta_box) { if (empty($meta_box) || !isset($meta_box['id'])) { continue; } $mb = new StdClass(); $mb->id = $meta_box['id']; $mb->title = $meta_box['title']; $mb->screen = $screen; $mb->context = $context; $mb->priority = $priority; $mb_hash = md5($mb->id . $mb->screen . $mb->context); self::$meta_boxes_list[$mb_hash] = $mb; } } } } update_option(self::META_BOXES_LIST_COPY_KEY, self::$meta_boxes_list); } // end of update_meta_boxes_list_copy()
where this condition was added:
if (empty($meta_box) || !isset($meta_box['id'])) { continue; }
After this reopen Coupon editor page and you will find at User Role Editor -> Meta Boxes needed metaboxes from Coupon editor page.
Revolution Slider adds its options meta box for the posts only by default. So I can not test it myself for coupons. I suppose that some plugin or theme makes that at your installation. But URE processes a ‘Revolution Slider Options’ meta box from post editor normally, so you should see it for coupons too.
Let me know the result. Thanks.
05/03/2016 at 04:10 #2089VladimirKeymasterHi Jawad,
This post describes how to use
woocommerce_duplicate_product_capability
filter.What settings did you make in “Admin Menu” for the “Vendor” role, for which PHP notices are generated? Please show a screenshot.
06/03/2016 at 01:30 #2090jawadParticipantHi Vladimir,
Thanks for the modified code. At first I thought it had made no different as when I check the list I thought ‘shop_coupon’ would be grouped together. However, these new coupon Meta Boxes now show at the end of the page separate to where Coupon Data is – nonetheless, this has fixed both Revolution Slider and Author Meta Box. Furthermore, when I create an order, my earlier issue post #2062 – this error no longer appears when I go to create an order.
Also – thank you for that post highlighting how to use duplicate product capability whilst keeping ‘manage_woocommerce’ enabled, it has worked perfectly!
The only remaining issue left is the PHP error message shown on ‘Vendor’ role.
Notice: Undefined offset: 3 in /user-role-editor-pro/includes/pro/classes/admin-menu-access.php on line 119
Here is the screenshot – I have not changed any of the settings or capabilities for ‘Vendor’ role:
And these are the capabilities:
Thanks for all your help, truly appreciate it!
Many Thanks,
Jawad06/03/2016 at 03:34 #2091VladimirKeymasterHi Jawad,
Thanks for the feedback. I very appreciate your help in making URE Pro better.
I can repeat the PHP notice from the admin-menu-access.php using your recent information.
I will develop a fix.06/03/2016 at 03:45 #2092VladimirKeymasterJawad,
I found and fix the reported issue with PHP notice from admin-menu-access.php. I will publish it with the next update in 1-2 weeks.
07/03/2016 at 00:21 #2093jawadParticipantHi Vladimir,
Glad this is both improving URE Pro and fixing my issues!
I was wondering if the new version will have ‘Hide Admin Notices’ as default or not?
As if it will then I will remove code from my functions.php as there is no point having it twice.
Many Thanks,
Jawad -
AuthorPosts
- You must be logged in to reply to this topic.