Skip Navigation

[Resolved] File upload with CRED: Edit form problem & change shown path

This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#576931
cred-edit-form-file-upload.png

Hi,

First question: Is there a way to change the shown path, after I uploaded a file with CRED (for both the creation and edit form)? At the moment it shows the full URL, which is really messy. I just want to show the file name.

Second question: With the CRED edit form I have a strange behaviour: If I already uploaded a file, then delete this file and add a new file, the old file path is shown again (see screenshot, the old path is added without link). No idea why, is this a bug?

Third question: Again only with the CRED edit form with a file already uploaded: The attribute "for" for the label gets a random string (like "3f30") instead of the id of the input field ("wpcf-beleg_file"). I even tried to add the "for" attribute in the CRED form editor, but it still gets overwritten with a random number. Is this a bug? Do you know how I can fix that?

Thanks in advance and best regards,
Michael

#577140

Hi, please create new tickets for each question. This will help you receive the most targeted answers, and will help us keep the forum organized. Thanks for understanding. I can handle the first question here.

First question: Is there a way to change the shown path, after I uploaded a file with CRED (for both the creation and edit form)?
You can add a custom shortcode that will display just the file name. Add this code to functions.php:

add_shortcode( 'my_file_name', 'my_file_name_func');
function my_file_name_func($atts)
{
  $urls = $atts['file_url'];
  $fileparts = explode('/', $urls);
  return end($fileparts);
}

Then you can show the file name by passing the file URL into the new custom shortcode:

[my_file_name file_url="[types field='my-file' output='raw']"]