Hi,
Meta Box Builder does not support getting the user name to use as the custom folder name. You need to use the PHP code to get the user name and assign it to the setting upload_dir
. For example, this code gets the current user name to use as a folder name.
function your_prefix_function_name1( $meta_boxes ) {
$current_user = wp_get_current_user();
$user_login = $current_user->user_login;
$meta_boxes[] = [
'title' => __( 'Post Meta1', 'your-text-domain' ),
'id' => 'post-meta1',
'fields' => [
[
'id' => 'file',
'name' => 'File',
'type' => 'file',
'upload_dir' => ABSPATH . '/myfolder/' . $user_login . '/',
],
],
];
return $meta_boxes;
}
Get more details on the documentation
https://docs.metabox.io/fields/file/#upload-to-custom-folder
https://developer.wordpress.org/reference/functions/wp_get_current_user/