Wordpress wordpress set user_id 2014-07-09 Tomislav Vlahović Leave a comment $user_id = (is_user_logged_in() && !empty($current_user)) ? $current_user->ID : ''; if(empty($user_id)){ $current_user = wp_get_current_user(); if($current_user instanceof WP_User){ $user_id = $current_user->ID; } }