I created an ACF field Text named 'user-dir' linked to the table 'users'.
- 'User Role' is equal to 'All'
- 'User Form' is equal to 'Add/Edit'
Normally, the ACF field is updated when user registers. That does not.
The belowed code must:
- create a directory with user_id => that works fine, the directory is created
- set the value of the ACF field 'user-dir' to 'bla bla bla' => that does not work and the ACF field 'user-dir' is not updated.
Could you help me please to understand what is wrong.
function create_user_dir($user_id) {
$upload_dir = wp_upload_dir();
wp_mkdir_p( $upload_dir['basedir'] . '/' . $user_id );
$userdir = 'bla bla bla';
update_field( 'user-dir', $userdir, $user_id );
}
add_action( 'user_register', 'create_user_dir');