50 lines
994 B
PHP
50 lines
994 B
PHP
<?php
|
|
|
|
function getRevueAuthors($revueID)
|
|
{
|
|
|
|
|
|
$revueRelatedArticles = new WP_Query(array(
|
|
'post_type' => 'articles',
|
|
'posts_per_page' => -1,
|
|
'post_status' => 'publish',
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => 'related_revue',
|
|
'value' => $revueID,
|
|
'compare' => '=',
|
|
),
|
|
),
|
|
));
|
|
$authors = array();
|
|
|
|
foreach ($revueRelatedArticles->posts as $article) {
|
|
$currentArticleAuthors = get_field('authors', $article->ID);
|
|
|
|
if (empty($currentArticleAuthors) || !is_array($currentArticleAuthors)) continue;
|
|
|
|
foreach ($currentArticleAuthors as $authorID) {
|
|
$authors[] = $authorID;
|
|
}
|
|
}
|
|
return array_unique($authors);
|
|
s;
|
|
}
|
|
|
|
|
|
function count_user_articles($userID, $postType)
|
|
{
|
|
$args = array(
|
|
'post_type' => $postType,
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => 'authors',
|
|
'value' => '"' . $userID . '"',
|
|
'compare' => 'LIKE',
|
|
),
|
|
),
|
|
);
|
|
$query = new WP_Query($args);
|
|
return $query->found_posts;
|
|
}
|