28
May
Select those users which name (Custom field) is empty
In the following I have created a custom field (name) in user profile, field machine name as field_name
I want get user list where name field is blank
$uids = \Drupal::entityQuery('user') ->condition('field_name', NULL, 'IS NULL') ->execute(); echo count($uids);
If you want to get more user through user id
foreach($uids as $uid){ $users = User::load($uid); $users->get('name')->value; }
© 2023.ZedAngle. All Rights Reserved.