Forum Replies Created
-
AuthorPosts
-
VladimirKeymaster
Code below removes all metaboxes from the post editor page for all users with “editor” role. Modify it for your own needs. Revisions metabox is ‘revisionsdiv’.
add_action('add_meta_boxes', 'remove_post_metaboxes', 11);function remove_post_metaboxes() {
if (!current_user_can('editor')) {
return;
}$side_metaboxes = array('formatdiv', 'categorydiv', 'tagsdiv-post_tag', 'postimagediv');
$normal_metaboxes = array('revisionsdiv', 'postexcerpt', 'trackbacksdiv', 'postcustom', 'commentstatusdiv', 'commentsdiv', 'slugdiv', 'authordiv');foreach($side_metaboxes as $metabox) {
remove_meta_box($metabox, 'post', 'side');
}
foreach($normal_metaboxes as $metabox) {
remove_meta_box($metabox, 'post', 'normal');
}}
add_action('add_meta_boxes', 'remove_page_metaboxes', 11);
VladimirKeymasterHi,
This code removes all HTML tags from the post content before save it for all users with ‘author’ role:
add_filter('content_save_pre', 'nohtml_in_posts');function nohtml_in_posts($content) {
if (current_user_can('author')) {
$content = wp_filter_nohtml_kses($content);
}return $content;
}
Include it into active theme’s functions.php file.VladimirKeymasterHi, this plugin does not introduce its own capabilities. It uses built-in WordPress
manage_options
user capability for its menu item:
https://storage.googleapis.com/role-editor/downloads/support/si-contact-form-capability.pngYou may find user capability for any admin menu item with a help of “Admin access add-on”:
https://www.role-editor.com/block-admin-menu-items
Just open it for the Administrator role and find needed menu item in the list.VladimirKeymasterThanks for the information.
Could you tell me from what plugin that custom menu is, so I may directly test URE with it?As about “Block not selected” option, it works currently as straightforward as it named – blocked (as result user is redirected) all not selected URLs. So if some link is clicked from the allowed page, but that link was not selected at menu items list (it may even be not presented there) user will not get access to it.
VladimirKeymasterHi,
Thanks. I found an issue in URE with your help:
Other default roles (in addition to the primary role) was assigned to a new registered user for requests from the admin back-end only. Now this feature works for the requests from the front-end user registration forms too.Try next update: development version 4.19.1.b2. It should work as expected now.
VladimirKeymasterIn order to edit published page, user should have ‘edit_published_pages’ capability. I added it directly to the user. checkman-test may edit allowed page now.
VladimirKeymasterHi,
OK. Thanks for letting me know, that you find an answer yourself.
VladimirKeymasterIs it possible to look on that data online? Send admin credentials to the [email protected]
VladimirKeymasterIf that post is from other author, then user should have ‘edit_others_posts’ capability to get permission to edit it.
VladimirKeymasterThanks for the information. It’s a strange effect. Roles editing core was not changed. So I can not repeat and explain it.
VladimirKeymasterTry this variant:
add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1); function _wc_disable_admin_bar($prevent_admin_access) { if ( !( current_user_can('data_entry') || current_user_can('operator') || current_user_can('manager') ) ) { return $prevent_admin_access; } return false; } add_filter('woocommerce_prevent_admin_access', '_wc_prevent_admin_access', 10, 1); function _wc_prevent_admin_access($prevent_admin_access) { if ( !( current_user_can('data_entry') || current_user_can('operator') || current_user_can('manager') ) ) { return $prevent_admin_access; } return false; }
VladimirKeymasterGood. Thanks for the information.
You may use one complex expression for all roles, like this one:
if (!(current_user_can('role1') || current_user_can('role2'))) { return .... }
VladimirKeymasterIt seems I found a problem with code. Replace ‘no’ to ‘false’. It should help.
add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1); function _wc_disable_admin_bar($prevent_admin_access) { return false; }
VladimirKeymasterOk. I will re-test this code myself.
VladimirKeymasterWhile it worked for me as it is, try to add filter with lower priority value – 9 instead of 10.
-
AuthorPosts