This useful PHP code snippet shows you how to use a WordPress function to get the current user id. This code shows creating the user id as a PHP string variable and displaying it using echo.