EDIT
I think the solution given by @dboris may work.
Alternatively you could try to hook your email sending after the user registration like this
global $uID; //to keep the value to reuse it later, null at this step
function mailInscriptionSecteurRhone() {
global $uID;
$user_ID = $uID;
$headers = array('Content-Type: text/html; charset=UTF-8');
$candidat = get_userdata( $user_ID );
$codePostalCandidat = get_field('code_postal', 'user_' . $user_ID );
wp_mail( '[email protected]', 'Test', $codePostalCandidat, $headers );
}
function trigger_mailInscriptionSecteurRhone($user_ID)
{
global $uID;
$uID = $user_ID;
add_action( 'init', 'mailInscriptionSecteurRhone', 10 );
}
add_action( 'user_register', 'trigger_mailInscriptionSecteurRhone', 10,1 );
Instead of sending directly the email with the “not ready” data, we trigger the next init hook which is supposed to do it. We can keep the user id by using a global variable.
I did not test this solution, it is a suggestion.
End edit
Ok maybe the user_register hook is triggered before acf is loaded (acc to your screenshot, you use acf)
So, have you tried get_user_meta like this ?
$codePostalCandidat = get_user_meta($user_ID,'code_postal',true);