acf_ct/edit_read_only_field

Used to allow non-admin user to update read-only field value

Parameters

apply_filters( "acf_ct/edit_read_only_field", $is_read_only, $field);
  • $is_read_only Boolean
  • $field ACF field array

Example

 function make_field_read_only($is_read_only, $field) {

		/**
     * Admin and editor can edit read-only fields
     */
    if ($field['name'] === "status && (current_user_can("administrator") || current_user_can("editor"))) {
      return true;
    }

    return $is_read_only;
 }

// Apply to all fields.
add_filter('acf_ct/set_sql_data_type', 'make_field_read_only', 10, 2);

Upgrade to PRO