Estamos trabajando para traerte una nueva experiencia en nuestro sitio web. Muy pronto estará listo. ¡Gracias por tu paciencia!" Dismiss

Skip to content
No results
  • Home
  • Tutorials
  • Plugins
    • Wizard Cart Import
    • AR Model Viewer for WooCommerce
  • Projects
  • Tools
  • Contact
LinkedIn GitHub WordPress WhatsApp TikTok
LinkedIn GitHub WordPress WhatsApp TikTok
racmanuel.dev
  • Home
  • Tutorials
  • Plugins
    • Wizard Cart Import
    • AR Model Viewer for WooCommerce
  • Projects
  • Tools
  • Contact
Contacto

racmanuel.dev

AR Model Viewer for WooCommerce

4
  • Getting Started
  • Description
  • Requisites
  • Installation Guide

Custom Fields Booster

3
  • Address
  • Read Only
  • Rating / Stars
View Categories
  • Home
  • Docs
  • Custom Fields Booster
  • Read Only

Read Only

4 min read

Description #

Displays a read-only value while still saving the field normally.

The field renders a locked UI but persists its value using a hidden input, ensuring full compatibility with ACF saving logic, REST API output, and frontend forms.

Use Cases #

  • Display system-generated values
  • Show calculated or derived data
  • Expose synchronized API values
  • Prevent accidental edits on critical fields
  • Display technical identifiers such as IDs, tokens, or hashes

Field Preview #

Locked value rendered as a box, inline text, or code block.
The value is visible but not editable.

How to Use #

  1. Add the Read Only (Locked) field to a Field Group
  2. Choose the desired Display style
  3. Optionally enable the Copy button
  4. Optionally select another field as the display source
  5. Save the Field Group and edit a post

No custom code is required.

Field Settings #

SettingDescriptionDefault
Display styleVisual rendering mode (box, inline, code)box
PlaceholderText shown when the value is emptyEmpty
Show copy buttonEnables copy-to-clipboard buttonEnabled
Display sourceSelect which value is displayedThis field value
Other field name/keyField to mirror (display-only)Empty

Value & Storage #

  • Saved as: Post meta
  • Storage type: Hidden input
  • Return format: string | null
  • Formatting: Display-only formatting does not affect stored value

Arrays and objects are automatically converted to JSON strings.

Output Examples #

PHP (Theme / Plugin) #

$value = get_field('my_read_only_field');
echo esc_html($value);

Twig #

{{ fn('get_field', 'my_read_only_field') }}

Compatibility #

  • Repeaters
  • Flexible Content
  • Options Pages
  • Frontend forms (acf_form)
  • REST API
  • Multisite

Hooks (Developer) #

Hooks Summary #

HookTypePurpose
cfb/field/read_only/defaultsFilterModify default settings
cfb/field/read_only/supportsFilterModify ACF support flags
cfb/field/read_only/field_type_infoFilterOverride field metadata
cfb/field/read_only/save_valueFilterModify value before saving
cfb/field/read_only/display_value_rawFilterModify raw display value
cfb/field/read_only/display_value_stringFilterModify final display output
cfb/field/read_only/show_copyFilterControl copy button visibility
cfb/field/read_only/effective_post_idFilterControl display context
cfb/field/read_only/before_renderActionRun logic before render
cfb/field/read_only/after_renderActionRun logic after render

Filters #

Defaults #

Filter: cfb/field/read_only/defaults
Purpose: Override default field configuration globally
When: You want consistent defaults across all instances

add_filter('cfb/field/read_only/defaults', function ($defaults) {
    $defaults['display_style'] = 'inline';
    $defaults['show_copy'] = 0;
    return $defaults;
});

Supports #

Filter: cfb/field/read_only/supports
Purpose: Control ACF support flags such as required
When: Validation or compatibility needs adjustment

add_filter('cfb/field/read_only/supports', function ($supports) {
    $supports['required'] = false;
    return $supports;
});

Field Type Info #

Filter: cfb/field/read_only/field_type_info
Purpose: Override field metadata such as visibility or REST support
When: Customizing how the field appears in the picker

add_filter('cfb/field/read_only/field_type_info', function ($info) {
    $info['public'] = false;
    return $info;
});

Save Value #

Filter: cfb/field/read_only/save_value
Purpose: Modify the value before it is saved
When: Normalizing or sanitizing data

add_filter(
    'cfb/field/read_only/save_value',
    fn ($value) => strtoupper($value)
);

Display Value (Raw) #

Filter: cfb/field/read_only/display_value_raw
Purpose: Modify the value before string conversion
When: Working with numbers, arrays, or objects

add_filter(
    'cfb/field/read_only/display_value_raw',
    fn ($display) => is_numeric($display) ? number_format($display) : $display
);

Display Value (String) #

Filter: cfb/field/read_only/display_value_string
Purpose: Modify the final displayed string
When: Adding prefixes, labels, or formatting

add_filter(
    'cfb/field/read_only/display_value_string',
    fn ($display) => 'ID: ' . $display
);

Copy Button #

Filter: cfb/field/read_only/show_copy
Purpose: Control copy button visibility
When: Restricting copy access by role or context

add_filter(
    'cfb/field/read_only/show_copy',
    fn () => current_user_can('manage_options')
);

Effective Post ID #

Filter: cfb/field/read_only/effective_post_id
Purpose: Define the context used to read mirrored fields
When: Working with options pages, users, or terms

add_filter(
    'cfb/field/read_only/effective_post_id',
    fn () => 'options'
);

Actions #

Before Render #

Action: cfb/field/read_only/before_render
Runs immediately before rendering the field UI

add_action('cfb/field/read_only/before_render', function ($field) {
    // Pre-render logic
});

After Render #

Action: cfb/field/read_only/after_render
Runs after the field UI has been rendered

add_action(
    'cfb/field/read_only/after_render',
    function ($field, $value, $display) {
        // Post-render logic
    },
    10,
    3
);

Assets #

Scripts and styles are automatically enqueued for admin edit screens and frontend forms using acf_form().

Customization #

add_filter(
    'cfb/field/read_only/enqueue_script_args',
    function ($args) {
        $args['deps'][] = 'acf-input';
        return $args;
    }
);

REST API #

  • Schema: string | null
  • Output: Raw stored value
{
  "my_read_only_field": "ABC-123"
}

Security & Escaping #

  • Output is escaped internally
  • escaping_html support is enabled
  • Template output should still be escaped when applicable

Notes / Limitations #

  • Not a disabled input
  • Display source does not overwrite stored value
  • Formatting affects display only

Changelog #

  • 1.0.0 — Initial release
Updated on 23/12/2025
Free

Was the documentation helpful?

  • Happy
  • Normal
  • Sad
AddressRating / Stars
Table of Content
  • Description
  • Use Cases
  • Field Preview
  • How to Use
  • Field Settings
  • Value & Storage
  • Output Examples
    • PHP (Theme / Plugin)
    • Twig
  • Compatibility
  • Hooks (Developer)
    • Hooks Summary
    • Filters
      • Defaults
      • Supports
      • Field Type Info
      • Save Value
      • Display Value (Raw)
      • Display Value (String)
      • Copy Button
      • Effective Post ID
    • Actions
      • Before Render
      • After Render
  • Assets
    • Customization
  • REST API
  • Security & Escaping
  • Notes / Limitations
  • Changelog

racmanuel.dev

Ayudamos a crecer tu empresa mediante soluciones tecnológicas personalizadas. Nos especializamos en desarrollar herramientas que optimizan procesos, aumentan la eficiencia y generan resultados visibles.

Información de Contacto

  • Teléfono: +52 (444) 380 57 40
  • WhatsApp: +52 (444) 380 57 40
  • Correo: developer@racmanuel.dev
  • Dirección: 78250 San Luis Potosí, S.L.P., San Luis Potosí, México
  • Home
  • Tutorials
  • Plugins
  • Projects
  • Tools
  • Contact

Copyright © 2024. Hecha ❤️ con WordPress.