2016-12-14 67 views
0

我在我的一个网站上有一个Gravity窗体图像上传表单,我试图让这个表单提交的图像上传到一个文件夹pdfs /(用户姓氏) - (用户名字)。重力格式gform_upload_path不正确地移动图像

我使用的是gform_upload_path过滤器,文件被移动到pdf文件夹中,但没有移到用户的特定文件夹中。我在这里使用这个代码。

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; 
} 

回答

0

我想通了。其中一部分是缓存问题,但这是我最终的代码。

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; 
}