Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display Calculated fields on Profile?


  • willandmae
    Participant

    @willandmae

    Greetings everyone,

    Hope all are having an awesome day today. Simple question, How does one show calculated fields on the profile from data entered into the profile?

    For example: user enters “current weight”, “weight loss weight” and starting weight. Then I could display, weight lost so far = starting weight – current weight or amount to loose = starting weight – (current weight-weight loss weight) and so forth? Thanks for any help…

    Will

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    Create a template overload of this file:
    buddypress\bp-templates\bp-legacy\buddypress\members\single\profile\profile-loop.php

    Look at bp_the_profile_field_name() and bp_the_profile_field_value() – they display the value.

    You’ll need to write a conditional using
    bp_get_the_profile_field_name and bp_get_the_profile_field_value() so that you can use the values without displaying them.

    For example:

    if( bp_get_the_profile_field_name() == 'current_weight' )
      $current_weight = bp_get_the_profile_field_value(); 
    
    if( bp_get_the_profile_field_name() == 'starting_weight' )
      $starting_weight = bp_get_the_profile_field_value(); 
    
    $weight_lost = $starting_weight - $current_weight; 
    
    echo '<br/>weight lost so far: ' . $weight_lost;

    willandmae
    Participant

    @willandmae

    @shanebp Thank you so very much for the examples. I wish I knew more of what I was doing to implement it. Was kind of hoping their could have been some way to calculate this on the profile page through a simple additional field-such as a display only field. I wish I was smart like you and this would be a no brainer and it would be done already….

    Will

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display Calculated fields on Profile?’ is closed to new replies.
Skip to toolbar