You probably called it too early, get_current_user_id
uses wp_get_current_user
, so move all your code that’s at the top level of functions.php
into the init
hook or appropriate equivalent. The only thing that should be in the global scope in your functions file if you want maximum compatability and efficiency is add_action
and add_filter
calls