• Resolved erlkismaksem

    (@erlkismaksem)


    Hi there,

    Cover photos are being uploaded to my uploads folder. How can I set a custom upload folder like this:

    “wp-content/uploads/covers”

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author SeventhQueen

    (@seventhqueen)

    Hi, we are using the wp_handle_upload function which supports this filter:
    apply_filters( ‘wp_handle_upload’, array(
    ‘file’ => $new_file,
    ‘url’ => $url,
    ‘type’ => $type
    ), ‘wp_handle_sideload’ === $action ? ‘sideload’ : ‘upload’ );

    we use for $action ‘bp_upload_profile_cover’

    Thread Starter erlkismaksem

    (@erlkismaksem)

    Thanks for your respone.

    Do you have an example of code I can put in my functions to make this work? I’m not quite sure how to implement your suggestion.

    I tried using this with no luck:

    add_filter('upload_dir', 'my_upload_dir');
    	$file = wp_upload_dir();
    remove_filter('upload_dir', 'my_upload_dir');
    
    function my_upload_dir($file) {
    	$file['subdir']		= '/covers' . $file['subdir'];
    	$file['path']		= $file['basedir'] . $file['subdir'];
    	$file['url']		= $file['baseurl'] . $file['subdir'];
    return $file;
    }
    

    Thanks!

    • This reply was modified 8 years, 3 months ago by erlkismaksem.
    • This reply was modified 8 years, 3 months ago by erlkismaksem.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom upload folder’ is closed to new replies.