function social_user_export_posts_count in Open Social 8.2
Same name and namespace in other branches
- 8 modules/social_features/social_user_export/social_user_export.module \social_user_export_posts_count()
Returns quantity of posts created by specific user.
Parameters
\Drupal\user\UserInterface $account: The account to get the data for.
Return value
int Quantity of posts created by the account.
1 call to social_user_export_posts_count()
- ExportUser::exportUserOperation in modules/
social_features/ social_user_export/ src/ ExportUser.php - Callback of one operation.
File
- modules/
social_features/ social_user_export/ social_user_export.module, line 172 - The Social User Export module.
Code
function social_user_export_posts_count(UserInterface $account) {
$query = \Drupal::database()
->select('post', 'p');
$query
->join('post_field_data', 'pfd', 'pfd.id = p.id');
$query
->condition('pfd.user_id', $account
->id());
return (int) $query
->countQuery()
->execute()
->fetchField();
}