The answer to your question is literally the title with underscores instead of spaces:
$user_id = get_current_user_id();
https://developer.wordpress.org/reference/functions/get_current_user_id/
The answer to your question is literally the title with underscores instead of spaces:
$user_id = get_current_user_id();
https://developer.wordpress.org/reference/functions/get_current_user_id/