Sum of all custom field values posted by specific user
-
So, I know this is possible, but I’m stuck
I’ve got it to sum all the values of the custom fields in general, but I want it to be specific to the current user logged in. If that makes sense, here is what i have so far:
`<?php
$miles = array();
$meta_key = ‘miles’;//custom field meta key
$miles = $wpdb->get_col($wpdb->prepare(“SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s”, $meta_key));
echo ‘You have run’.array_sum( $miles );
?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sum of all custom field values posted by specific user’ is closed to new replies.