You have added get_current_user_id();
in single quote. please remove quote from 'get_current_user_id()';
.
function get_meta_value_by_meta_key(){
$author_id = get_current_user_id();
// do stuff to get user I
$author_posts = get_posts( array('author' => $author_id, 'numberposts' => -1 ));
// needed to collect the total sum of views
$counter = 0;
// needed to collect the total sum of views
echo '<h3>Post views by Author:</h3><ul>';
// do stuff to get author name
foreach ( $author_posts as $post ) {
$views = absint( get_post_meta( $post->ID, 'Creation_Views', true ) );
$counter += $views;
echo "<li>{$post->post_title} ({$views})</li>";
}
echo "</ul><hr /><p>Total Number of views: <strong>{$counter}</strong></p>";
}
add_shortcode('Stats', 'get_meta_value_by_meta_key');