How to get all contents from which the current user is author?
$currentUser = \Drupal::currentUser();
$user = User::load($currentUser->id());
//get the contents from which $user is author?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this community$currentUser = \Drupal::currentUser();
$query = \Drupal::entityQuery('node');
$query->condition('uid', $currentUser->id());
$author_nids=$query->execute();
entityQuery
(orloadByProperties
) for each type you're interested in, with a condition for the author field based on the user id. If you want to write something generic, you can inspect the entity keys to see what field the entity type uses as itsowner