Menu bar settings appearing for ohter users than admin
-
Hi. Not sure what has happened here but suddenly the menu bar settings are visible/available to other users than admin (in my case Woocommerce vnedors? How do I limit access to just admin (running currently WP 5.5.3)?
-
The menu bar settings appears for those users who have the
manage_options
capability.https://wordpress.org/support/article/roles-and-capabilities/#manage_options
Is it possible that you added that capability to your vendors?
Hi,
Installed a plugin to analyze the capabilities and the Vendor does not have manage_options capabilities, just the basics of read, upload_files, edit_posts and some woocommerce capabilities.
The Mobile contact bar does not show up in the menu, it only appears as the widgets when editing a product, the edit url is: wp-admin/post.php?post=xxxx&action=edit
The mobile contact bar “widgets” show up in the display settings: (image here) and the edit page: (25% page view here) in the product edit page.
Is it possible that the menu item is controlled by the capability but the Vendor plugin somehow “rounds up available widgets” and they are not controlled/limited by the capability?
Sorry, seems the elements are meta boxes, not widgets.
I tried to “brute force” the problem:
function remove_my_post_metaboxes() { remove_meta_box( ‘mcb-section-model’,’post’,’side’ ); remove_meta_box( ‘mcb-section-model’,’product’,’side’ ); remove_meta_box( ‘mcb-section-bar’,’post’,’normal’ ); remove_meta_box( ‘mcb-section-bar’,’product’,’normal’ ); } add_action(‘add_meta_boxes’,’remove_my_post_metaboxes’,50);
but that did not work either.
So for some reason, the vendor product page picks up your meta boxes, do you limit the visibility with the add_meta_box() $screen parameter?
Thank you for the detailed description and the images, now I understand the issue better.
Yes, I limit the visibility with the
$screen
parameter, in theincludes/class-page.php
when I calladd_meta_box()
. And despite of that you can see the metaboxes onpost.php
.If I deactivate all plugins except the WooCommerce and the Mobile Contact Bar, everything works fine.
I am trying to find out what is going on.
I am in the dark, because I cannot reproduce the problem.
I need your help with this:
1. Can you tell me which plugin or extension triggers the error?
This would be the best option, because I would be able to see the source code of that plugin too. No matter if the plugin is paid.2. Can you give me access to your development or staging site?
I am not sure how this could help, I would just follow my instincts.3. Can you try to install this plugin, and check if it has no issue?
If this plugins has no issues, then I would follow its implementation in the mobile bar.- This reply was modified 3 years ago by Anna Bansaghi.
- This reply was modified 3 years ago by Anna Bansaghi.
1) The problem occurs when a vendor edits a product with this plugin: Vendor plugin, not sure if the free version has the same behavior?
2) Just migrated my site to a new hosting which recreated the staging site from live which unfortunately means I have full customer info still on that site so cannot provide externals access at this time :-(.
3) The plugin did not perform very well 🙂 as you can see from this screen grab and this screen grab 2.
I even tried this for fun:
public static function add_meta_boxes() { global $wp_settings_sections; if (is_admin()) {
but even this did not prevent the metaboxes from appearing.
So is there some way for the Vendor plugin to query what metaboxes might be needed to support editing the product and then calls those metaboxes? If yes, why would the mcb metaboxes then be identified as something linked to products?
Also, on this page, what would be the equivalent of your admin page to the ‘wporg_cpt’ screen name? Using something more specific instead of the self::$page (or are they the same, don’t know codign well enough to know what’s going on here, just a guess).
pps: what does the “self::$page” expand to, from my brute force testing something other than “post” or “product”?
I have installed the Vendor plugin both the free and the paid one, and still no issues. However I found something which might be the problem.
In my case the unique identifier for the meta boxes is stored in
self::$page
, and its value issettings_page_mobile-contact-bar
.I think that adding this piece of code should help:
$screen = get_current_screen(); if ( $screen->base !== self::$page ) { return; }
This code snippet should be in the
add_meta_boxes
function inincludes/admin/class-page.php
, like this:public static function add_meta_boxes() { $screen = get_current_screen(); if ( $screen->base !== self::$page ) { return; } global $wp_settings_sections; // <-- rest of the code starts add_meta_box( ...
What do you think can you try this first and check if it solves the problem, or do you want me to create a new version of the MCB plugin?
- This reply was modified 3 years ago by Anna Bansaghi.
Thanks, this did solve the problem! No need to update the plugin at this time, but staging and live are now fixed. But thankful if you include this in your next regular update so it is not lost when updating!
Oh, I am very glad! Thank you for your time and helping me to fix this bug!
- The topic ‘Menu bar settings appearing for ohter users than admin’ is closed to new replies.