phpBB user IDs start at 2 (ID of 1 is anonymous), so IDs can't be 0. Therefore, you can just test for a non-empty value. You can shorten this code to:
`$user_id = $user_id ?: $this->user->data['user_id'];`