ACF User Role Field Setting | John A. Huebner II | acf

ACF User Role Field Setting | John A. Huebner II | acf,advanced custom fields,security,setting,user role

Description

This is an add on plugin for Advanced Custom Fields (ACF) Version 5.

This plugin will not provide any functionality if ACF5 is not installed.

This plugin adds a field setting to all field types so that user roles allowed to edit the field can
be selected. Only those roles selected for the field will be able to edit the field.

Github Repository

This plugin is also on GitHub
https://github.com/Hube2/acf-user-role-field-setting

Excluded Field Types

Most of the time it would not make sense for a tab field, unless all of the fields in the tab were set the same, in other words, removing a tab should remove all the fields in that tab. That’s not something that I can do at this point.

I’m not sure about the clone field, I haven’t worked with it much. You can test it out if you want.

I have also removed support for repeater, group and flexible content fields because I cannot preserver the values of these fields if they are not editable in the ACF interface. Please note that I do not know what the effect of allowing user role settings on these fields will be.

There is a filter so that you can adjust the types of fields that are excluded. Here is an example

<?php 

  add_filter('acf/user_role_setting/exclude_field_types', 'user_role_setting_excluded_field_types');
  function user_role_setting_excluded_field_types($exclude) {
    /* 
      $exclude holds an array of field types to exclude from adding user role settings
      default value:
      $exclude = array('tab' => 'tab', 'clone' => 'clone');
    */

    // remove tab field from exclude
    if (isset($exclude['tab'])) {
      unset($exclude['tab']);
    }

    // add message field to exclude
    $exclude['message'] = 'message';

    return $exclude;
  }

?>

Installation

Install like any other plugin

Plugin author

John A. Huebner II

Plugin official website address

https://wordpress.org/plugins/user-role-field-setting-for-acf/
If you encounter problems in using the ACF User Role Field Setting plugin, you can comment below, and I will try my best to help you solve the problem

Leave a Comment

Your email address will not be published.