Support

Account

Home Forums Add-ons Flexible Content Field Disable add/delete/move Flexible Content for non-admins

Helping

Disable add/delete/move Flexible Content for non-admins

  • Hi there,

    Is there any way to disable the add/delete/move options for non-admins? I’d like my clients to simply edit the content, but no more than that.

    I think I could remove some of the features with CSS, but if there is a more natural approach i’d like that instead.

    I use Advanced Custom Fields: Extended as well if that makes a difference.

    Best,
    Dave

  • 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);
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.