Custom Fields
Re-Envisioned
Support General Show field in frontend but not allow to edit by the user

This topic contains 4 replies, has 2 voices, and was last updated by  proyectohappyweb@gmail.com 2 months, 3 weeks ago.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #14325

    Anh Tran
    Keymaster

    Hi Sergio,

    Yes, it can be done with a condition like this:

    [
        'type' => 'text',
        'id' => 'field_id',
        'name' => 'Text field',
        'disabled' => ! is_admin(), // This disables editing in the front end.
    ]
    #14330

    ooh perfect!!! Many thanks.

    #14352

    Hello,

    I have a proble using:
    ‘disabled’ => !is_admin(), // This disables editing in the front end.

    With a meta box with:
    ‘storage_type’ => ‘custom_table’, // Important

    Is that all fields are saved well in the custom table except the fields that I put ‘disabled’ => !is_admin()…

    Have you detected if it is a general error? Or does it just happen to me?

    I try to put this like this
    ‘attributes’ => array(
    ‘disabled’ => true,
    ),
    But it doesn’t matter, not save the value…

    Thanks.

    #14355

    Hello,

    I try this:
    ‘readonly’ => true,
    and it run ok!! Users can’t edit the field and the value is saved in the custom table.

    Sergio

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.