Site icon Hip-Hop Website Design and Development

Replace consumer meta of creator when submit content material is seen

I’ve a worth that I am making an attempt to retailer as consumer meta for authors on my web site. I would like it to replace itself each time the content material of a submit is seen for that creator. This is so far as I’ve gotten nevertheless it is not storing the worth. I exploit this in features.php.

perform user_score() {
    world $bp;
    $author_id = $bp->displayed_user->id; // do stuff to get consumer ID

    $author_posts = get_posts( array(
      'creator' => $author_id,
      'posts_per_page' => -1
    ) );

    $counter = 0;
    foreach ( $author_posts as $submit )
    {
      $rating = get_post_meta( $post->ID, 'ratings_score', true );
      $counter += $rating;
    }
    update_user_meta( $author_id, 'user_score', $counter );
    if ($echo)
      echo $counter;
    return $counter;
}
add_filter('the_content','update_user_score');
perform update_user_score($content material){
  world $submit;
  user_score();
  return $content material;
}