Hi There,
I am trying to hide metabox fields based on user role. For that I am trying to use rwmb_before
action. The code is pasted below.
The problem that I am getting is that I can remove the field for a specfic user role. However, the hidden field loses its saved value. How can I preserve the value while hiding the fields for specific roles?
add_action('rwmb_before' , 'ta_hide_metabox_fields', 10, 1);
function ta_hide_metabox_fields($object){
print "<pre>";
print_r($object->meta_box['fields']);
print "</pre>";
foreach ($object->meta_box['fields'] as $idx => $item){
/* print "<pre>";
print_r($idx);
print "</pre>";
print "<pre>";
print_r($item);
print "</pre>";
*/
if($item['id'] == 'specialty'){
unset($object->meta_box['fields'][$idx]);
}
}
}
Thanks!