Home › Forums › Add-ons › Flexible Content Field › Disable add/delete/move Flexible Content for non-admins › Reply To: Disable add/delete/move Flexible Content for non-admins
There are 2 ways you can do this.
1) Add an ‘admin_head’, action that outputs CSS to hide controls if the user is not an admin.
2) The second way is with JavaScript, you can remove the controls completely something like this is a basic example, I’m sure I’m missing something but it might get you started
(function($){
if (typof acf === 'undefined') {
return;
}
acf.add_action('ready append') {
// target all flex fields
// you can adjust this selector to target specific flex fields
// but adding [data-key="field_XXXXX"] before the selector
$('.acf-flexible-content a').each(function(index, element) {
$(element).remove();
});
}
}(jQuery);
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.