Support

Account

Home Forums Add-ons Flexible Content Field How to hide delete button on layouts for non admin users?

Helping

How to hide delete button on layouts for non admin users?

  • Hello!
    I would like to remove/hide the delete button on layouts for non admin users, in order to prevent any inadvertent action.
    Any tip?

    Thank you very much.

  • Hi @bonjour

    I believe you can remove it by adding JS script using the acf/input/admin_footer hook like this:

    add_action('acf/input/admin_footer', 'my_acf_admin_footer');
    function my_acf_admin_footer() {
        
        ?>
        <script type="text/javascript">
        (function($) {
            
            $(document).ready(function(){
    
                $(".acf-fc-layout-controlls a[data-event='remove-layout']").parent().remove();
                
            });
            
        })(jQuery);    
        </script>
        <style type="text/css">
            
        </style>
        <?php    
        
    }

    I hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.