wordpress set user_id

$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;
  }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.