I found a code scrap on the internet which uses
if($user_id) {
instead of
if ( is_user_logged_in() ) {
to check if the user is logged in. I would assume that the first would be slightly faster because it's not running a function, but can anyone verify that this would always work?