I have a Gravity forms image upload form on one of my websites and I am trying to get the images submitted by this form to upload to a folder pdfs/(user last name)-(user first name).
I'm using the gform_upload_path
filter and the file gets moved to the pdfs folder but not into the user's specific folder. I'm using this code here.
add_filter("gform_upload_path", "change_upload_path", 10, 2);
function change_upload_path($path_info, $form_id){
//global user ID of current logged in user
global $user_ID;
//get the first name and last name from the usermeta table
$last_name = get_user_meta($user_ID, 'last_name', true);
$first_name = get_user_meta($user_ID, 'first_name', true);
$path_info["path"] = "pdfs/". $last_name ."-". $first_name ."";
$path_info["url"] = "https://workatkeepmehome.com/pdfs/".$last_name."-".$first_name."";
return $path_info;
}
I figured this out. Part of it was a caching issue but here is the final code I ended up with.