function addOne() {
$user_id = $_SERVER["QUERY_STRING"];
$key = 'viewcount';
$view_count = get_user_meta($user_id, $key, true);
$view_count += 1;
echo 'view_count is:'. $view_count;
update_user_meta($user_id, $key, $view_count);
return $view_count;
}
Each time I visit http://www.mysite.com/single-page?15
This function should increase by one the custom meta field “viewcount” related to user 15
It’s almost working… except that instead of increasing by one it’s increasing by two the field.
(The function is written in function.php (of the theme I’m currently using) and I call it from the html content of a post using a plugin to execute Php, just to call it)
What’s wrong?
thank you!
Giacomo