WordPress wp_get_current_user returning blank values until refresh
Your header.php file is going to be called after the init action. If you want the logic to run in your header.php file first, maybe you can hook into another action done at a later point in WordPress: add_action(‘wp_head’, ‘ax_get_user_info’); function avox_get_user_info() { if (is_user_logged_in()) { $currentUser = wp_get_current_user(); $fName = $currentUser->user_firstname; } return $fName; … Read more