Home › Forums › Feature Requests › Hide Elements for specific user roles
Hello,
ist it possible to hide elements ( https://ibb.co/fRpDH9 ) only for specific user roles?
Thanks in advance!
Thanks for your reply.
But I don’t want to hide FIELDS, I want to hide elements on the page like the editor etc. This is the option in the settings: https://ibb.co/ik8tKp
No, that is not possible through settings. You can create a filter, there is an undocumented filter acf/get_field_group
add_filter('acf/field_group', 'my_change_field_group');
function my_change_field_group($group) {
if ($group['key'] = 'group_your-group-key') {
// check current user role
// set $group['hide_on_screen'] with array of things you want to hide
// look at an exported field group for examples of what goes here
}
return $group;
}
@hube2 I think that this filter stopped working in the latest version 🙁
It depends on what you’re trying to hide on screen and what editor you’re using. If you using guberbuggutenberg then hiding the editor will not work. Not sure about other things.
@omikr0n please use “acf/get_field_group” because the code snippet uses an incorrect “acf/field_group”.
But I still can’t seem to hide the group through PHP with this filter.
Even if I’m setting the $group[‘active’] to false.
I managed to remove a group via the metabox removal code
remove_meta_box('acf-group_58638dba80441', 'your-custom-post-type-here', 'normal');
‘normal` can also be ‘side’ depending on the position.
See https://support.advancedcustomfields.com/forums/topic/remove-a-metabox-from-edit-page/
Is this what helps y’all?
The topic ‘Hide Elements for specific user roles’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.