hy, in order to remove some metabox in the wp editor for not-administrator users, i’m using this function:
****************************
if (is_admin()) :
function my_remove_meta_boxes() {
if( !current_user_can(‘manage_options’) ) {
remove_meta_box(‘postcustom’, ‘post’, ‘normal’);
}
}
add_action( ‘admin_menu’, ‘my_remove_meta_boxes’ );
endif;
****************************
it works but if i want also to hide some of your theme boxes, the function doesn’t work. for example i add this:
****************************
remove_meta_box(‘td_post_video_metabox’, ‘post’, ‘normal’);
remove_meta_box(‘td_post_theme_settings_metabox’, ‘post’, ‘normal’);
remove_meta_box(‘td_review_metabox’, ‘post’, ‘normal’);
remove_meta_box(‘rs_post_editor’, ‘post’, ‘normal’);
remove_meta_box(‘rs_post_contributor’, ‘post’, ‘normal’);
remove_meta_box(‘rs_private_post_reader’, ‘post’, ‘normal’);
****************************
why? where i am wrong?
thnak you
Hi,
The theme uses the WPAlchemy_MetaBox class for adding meta boxes – http://screencast.com/t/O2OJkPt4
You could use the following function – https://codex.wordpress.org/Function_Reference/current_user_can – and replace the is_admin() condition.
Thank you, Emil G.
sorry, i’m afraid i do not understand how to do.
i need to hide these metaboxes (just some but not all) for no-admin users:
td_post_video_metabox
td_post_theme_settings_metabox
td_review_metabox
rs_post_editor
rs_post_contributor
rs_private_post_reader
can you please tell me what should i add in the functions.php?
thanks
Hi,
You have to modify the code like this – http://screencast.com/t/wdxG3EaCLY – http://screencast.com/t/A6wgqp98
current_user_can( 'manage_options' )
You cannot add it in the functions.php
Thank you, Emil G.
-
This reply was modified 11 years by
Emil G.
Hi,
Replace all code from this file: http://screencast.com/t/CEwcrJj11tT with this one: http://pastebin.com/9ySVNP7L
This will allow access to theme’s meta boxes just for super admin and accounts: https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
Thanks
Hi pbc,
Yes, that can be done; but now is no need, because you can set for each user what role to have https://www.screencast.com/t/jGhy6aoLoamR
Thank you.