2016-12-14 66 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; 
}