• I am trying to figure out how to get a SUM of two user_meta fields and post it back as a new value in the user_meta. The whole point is to then calculate a percentage. What I am posting already via the profile edit page is wins and losses that the user can input. Here is the rough code I have tried to use that is returning an error.

    update_user_meta( $user_id, SUM('sport1wins')+SUM('sports1loss'), $_POST['sport1total'] );

    Fatal error: Call to undefined function SUM()

Viewing 1 replies (of 1 total)
  • I think you want something like this (UNTESTED):

    $wins = get_user_meta($user_id,'sport1wins',true);
    $losses = get_user_meta($user_id,'sport1loss',true);
    $sum = $wins + $losses;
    update_user_meta( $user_id, 'sport1total', $sum);
Viewing 1 replies (of 1 total)
  • The topic ‘Adding together user_meta fields’ is closed to new replies.