Custom Fields
Re-Envisioned
Support General Change Destination Of Custom File Upload Field Type Reply To: Change Destination Of Custom File Upload Field Type

#13173

david.h
Participant

Hi Anh,

Thanks for the pointers, I have come across those before, although I’m interested in logical and structural separation.

Would this pseudocode work, and could Metabox handle being returned an error?


array(
    'upload_dir' => fnCreateOrReturnFolder
)

fnCreateReturnFolder {
    $userdir = get_current_user_id()
    if $userdir != 0 {
        $userdirpath = '/path/to/users/folders/' . $userdir
        if ( !file_exists($userdirpath) ) {
            if ( wp_mkdir_p( $userdirpath ) ) {
                return $userdirpath
            }
        }
    }
    return 'error'
}