Support

Account

Home Forums Add-ons Repeater Field Would like my repeater field to be read-only

Solving

Would like my repeater field to be read-only

  • Hi guys, I’m doing an estate homepage and using Woocommerce for displaying the apartments as “products” – without the possibility to add to cart.

    The current scenario is, that I’ve created a form for the visitor to sign-up on a waiting list for the apartment if it is currently occupied.

    Every sign-up gets displayed as a new row in the backend, exactly as its supposed.
    However the user in backend, can edit the information submitted by the visitor, which I don’t like the possibility of.

    Can I do something to make all the subfields read-only or disable them somehow, so the backend user only can view the information submitted and delete rows (in case the first one on the list is offered the apartment)?

    Thanks in advance

  • hi @scwebstarters-dk

    You can use a filter to disable fields by name.. see an example below where I disable 2 fields… you can even disable by role/capabilities etc.

    
    <?php
    /* START: Makes the 'Customer Name' and 'Customer ID' fields in Users Read-Only */
    function cc_make_customer_name_and_id_fields_in_users_read_only( $field ) {
      $field['disabled'] = 1;
      return $field;
    }
    add_filter('acf/load_field/name=cc_customer_name_user', 'cc_make_customer_name_and_id_fields_in_users_read_only');
    add_filter('acf/load_field/name=cc_customer_id_user', 'cc_make_customer_name_and_id_fields_in_users_read_only');
    /* END: Makes the 'Customer Name' and 'Customer ID' fields in Users Read-Only */
    ?>

    More info on the filter used can be found here.

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

You must be logged in to reply to this topic.