Support

Account

Home Forums Backend Issues (wp-admin) Set File Upload path to be editable

Solved

Set File Upload path to be editable

  • I have a File Upload field named ‘upload’ and want the URL field to be editable in the ADMIN for the post since in some instances I need to edit the URL from pointing to a file to pointing to a website – so basically I like to keep the file upload functionality but like to be able to change the URL in a few instances.

    By default ACF sets the URL text input field for file uploads to ‘readonly’ in the Post ADMIN ‘Edit” UI and therefore does not allow me to update the path. Is there a hook I can add to the functions file of my theme to make this field editable? Any help would be greatly appreciated.

  • A file upload field holds the ID of the file which is saved as an attachment post type. There isn’t any functionality in this field to allow for what you want to do. You would need to use another type of field for a link. In this case I would create a radio field to allow the editor to select “upload file” or “external link to file” and then I would create a file field and a url field that both had conditional logic to display based on the selection of the radio field.

  • Hi John – thanks so much for the very helpful answer – so much appreciated!

  • John – is there any resource or sample you could point me to on how to exactly set up a radio field and add conditional logic to a File field and a URL field based on this radio field?

  • Do you mean the setting up the fields or the outputting of the field on the front end?

    I don’t think that there is any in-depth explanation of conditional logic. You create a radio field and give it any number of values that you want. When you create another field you can then turn on conditional logic for that field. You then select the radio for under “show this field if” and set the value for that field that makes the new field appear.

    In the code you would do something like

    
    if (get_field('radio_field') == 'value 1') {
      // do one thing
      // like show a value in another field
    } elseif (get_field('radio_field') == 'value 2') {
      // do something else
    }
    
  • Hi John, thanks again for your time and giving such a helpful answer and pointer!

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

You must be logged in to reply to this topic.