PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Upload path doesnt work for featured image

  1. black_lady
    Member

    Hello,
    I added this code to the functions.php:
    ==============================================================

    add_filter("gform_upload_path", "change_upload_path", 10, 2);
    function change_upload_path($path_info, $form_id){
    global $current_user;
       get_currentuserinfo();
    
       $path_info["path"] = "C:/xampp/htdocs/mysite/upload-folder/" . $current_user->user_login . "/";
       $path_info["url"] = "http://localhost/mysite/upload-folder/" . $current_user->user_login . "/";
       return $path_info;
    }
    ==============================================================

    when I add: custom filed -> Field Type: "file upload" and Custom Field Name: "existing" - everything works fine: files go to this folder:
    http://localhost/mysite/upload-folder/admin
    ( where "admin" is eg. of user login).

    But when I add: image -> Set as Featured Image, my files goes to this folder:
    http://localhost/mysite/upload-folder

    I want to send files to the same folder as in the previous case.
    Any ideas?
    I will be grateful for the quick response.

    Posted 11 years ago on Thursday February 28, 2013 | Permalink
  2. This was not my experience. I added a post image field to the form and marked it as featured image. I added a custom field of the type file upload, and stored the value in an existing key. And I added a regular file upload field. I added the current user login name to my path and URL (as you have done) and when I submitted the form, the directory was created with my username, and all 3 files were uploaded there.

    Posted 11 years ago on Monday March 4, 2013 | Permalink
  3. black_lady
    Member

    Hi Chris,
    If You are go to Your site and please right-click on the image (featured image) "show url image".
    The address indicated on the photo in this directory (with Your username)?
    I'am asking, because I have uploaded image also in directory with username, but this same photo is in other directory and featured image on my website have adress from this second directory.

    Sorry form my english :)

    Posted 11 years ago on Tuesday March 5, 2013 | Permalink
  4. I see what you mean now. The featured image is located in wp-content/uploads. All the images used in the post are moved to the media gallery. This is WordPress functionality.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink