security – User media folder for each users on registration

Question

i need to create a “user folder” in media library for user registration using usermeta field, for example “billing_company”.. so, my purpose is to procect file url inside that folder from unlogged users and logged users with different usermeta field/email..

someone please can help me with snippet?
thanks you

function create_user_dir($user_id) {
$user_info = get_userdata( $user_id );

$upload_dir = wp_upload_dir();
$user_dir = $upload_dir['basedir'] . '/user_dirs/' . $user_info->billing_company;

wp_mkdir_p($user_dir); }
 add_action( 'user_register', 'create_user_dir');

0
Fabio 6 months 2022-06-19T09:21:08-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse