Support

Account

Home Forums Front-end Issues Using acf_form to display an existing custom post

Solving

Using acf_form to display an existing custom post

  • Hi,

    I used ACF to create a set of custom fields for a custom post type called “person”.

    I am using acf_form to add a new person and to edit an existing person on the frontend UI.

    Can I also use acf_form to display an existing person as “read only” – i.e. just show the data without allowing the user to change any of the fields ?

    If not, what would be the right way to do this ?

    Thanks,

    Amir.

  • What criteria is there that decided if the post can be edited or not?

    
    if (MEETS CRITERIA) {
      acf_form();
    } else {
      // Display the information using html, and acf functions
      // like any other template
    }
    
  • Thanks John for the reply.

    What I wish to do is create a page to display the data of a custom post type on the frontend, so in that page all the fields should be “read only” and not editable.

    I can create a page template for this purpose and display the data using HTML and PHP code. However my custom post type has multiple custom fields from different types – text, date, photos, reference to other posts, etc. Therefore it will require some coding to display and style all the information correctly (i.e. using rows, grouping fields together, etc.).

    Since acf_form already renders all the fields in the right structure on the frontend, I thought there might be some way to use it (or something else) also for the purpose of displaying the data without editing it.

  • The only way to do this would be to add custom JavaScript under the correct conditions to set the fields to readonly, or otherwise disable them. It is possible using the acf/load_field filter to set fields to read only or disabled, but this does not work with all ACF fields do to the jQuery libraries used for those fields.

    What I meant was to just display the data without formatting it to look like an input field.

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

You must be logged in to reply to this topic.