1

Goal : Get favorited posts IDs from authors ID.

Authors ID :

$currentid = $current_user->ID;
$fav_author_list = bp_follow_get_following( array( 'user_id' => $currentid ) );
echo implode(' ', $fav_author_list); 

Result : 1, 45, 9

Favorited Posts ID from one specific Author ID (1) :

$authorID = "1";
$ok = get_user_favorites($authorID, $site_id);
echo implode(' ', $ok); 

Result : 845, 895

I want Favorited Posts ID from multiple Authors ID (1, 45, 9) : NOT WORKING

$ok = get_user_favorites($fav_author_list, $site_id);
echo implode(' ', $ok); 

$fav_author_list should be an unique value and this is my problem because I want get_user_favorites from multiple values

get_user_favorites function :

function get_user_favorites($user_id = null, $site_id = null, $filters = null)
{
    global $blog_id;
    $site_id = ( is_multisite() && is_null($site_id) ) ? $blog_id : $site_id;
    if ( !is_multisite() ) $site_id = 1;
    $favorites = new UserFavorites($user_id, $site_id, $links = false, $filters);
    return $favorites->getFavoritesArray();
}

EDIT :

$currentid = $current_user->ID;
$fav_author_list = bp_follow_get_following( array( 'user_id' => $currentid ) );
$ok = get_user_favorites($fav_author_list[0]);
foreach ($ok as $name => $age) {
echo $name = $age;
}

I succeed to get some results from $fav_author_list[0] and $fav_author_list[1] etc, what I want is to get ALL results in same time

Mathieu
  • 797
  • 2
  • 6
  • 24

0 Answers0