重力形式 gform_upload_path 无法正确移动图像
Gravity Forms gform_upload_path Not Moving Images Correctly
我的一个网站上有一个 Gravity forms 图片上传表单,我正在尝试将此表单提交的图片上传到文件夹 pdfs/(用户姓氏)-(用户名字)。
我正在使用 gform_upload_path
过滤器,文件被移动到 pdfs 文件夹,但没有移动到用户的特定文件夹。我在这里使用这段代码。
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;
}
我想通了。部分原因是缓存问题,但这是我最终得到的最终代码。
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;
}
我的一个网站上有一个 Gravity forms 图片上传表单,我正在尝试将此表单提交的图片上传到文件夹 pdfs/(用户姓氏)-(用户名字)。
我正在使用 gform_upload_path
过滤器,文件被移动到 pdfs 文件夹,但没有移动到用户的特定文件夹。我在这里使用这段代码。
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;
}
我想通了。部分原因是缓存问题,但这是我最终得到的最终代码。
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;
}