• I’m trying to add:

    the values in 33 separate fields (possible daily actions) for the same participant. Can I put the [pdb_total filter=”energy_turn_lights_off>0&energy_unplug_chargers>0&….”] in the attributes of the Total daily action points field? And then take the total and multiply by 10? Actually, the participant can only select 8 daily actions, but I wouldn’t know which 8.

    the number of 17 separate fields with checkboxes (possible one-time actions) for the same participant. Can I put [pdb_total filter=”energy_change_to_led_lights.checked===true&nature_plant_a_tree.checked===true….”] in the attributes of the Total one-time action points field? And then take the total and multiply by 25?

    If not, how do I do that? Thanks!

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author xnau webdesign

    (@xnau)

    You can’t put a shortcode in a field attribute, it won’t work that way. Shortcodes can only be used on pages or in templates.

    To do what you’re asking about is going to require some custom code. You’ll need to create a custom template that can display the totals the way you want. The plugin doesn’t have this specific functionality built into it, but with some knowledge of php it’s possible.


    Using Participants Database Custom Templates

    Thread Starter crowwoods1

    (@crowwoods1)

    OK, I tried to follow your instructions and now have a custom record template to work with. I watched some YouTube tutorials. Here’s what I got. Am I close?

    To add up points for checkboxes:
    in the <td> section of the field loop after help text

    <?php if($this->field-group=field-group-one_time_activities”. and.$this->field->value()=”Completed”) )
    $points_for_one_time_challenges = $points_for_one_time_challenges + 25;
    <?php endif ?>

    <?php if($this->field_group=field-group-daily_activities”. and.$this->field->value()>0)
    $points_for_daily_challenges = $points_for_daily_challenges + ($this->field->value() * 10);
    <?php endif ?>

    </td>

    Print the total points after the group loop ends before submit buttons:

    <tr>
    <th><h3><?php $this->echo “Points for Challenges:” ?></h3></th>
    <td>
    <?php $this->print_points_for_one_time_challenges; ?>
    <?php $this->print_points_for_daily_challenges; ?>
    </td>
    <tr>`

    Thank you for your help! Sorry I’m kind of clueless. ??

    Plugin Author xnau webdesign

    (@xnau)

    It looks like you need some help with your basic php, your code is pretty far from being working code. I can’t provide coding lessons here, I’m sorry.

    Thread Starter crowwoods1

    (@crowwoods1)

    Hi again,

    I’m planning for next year’s Earth Day Challenge, and want to resolve my problem with not being to add up points for each participant, and also adding up team points automatically. I had used 3 different php forums to help me but none were able because they didn’t understand how Participant Database is set up. I’ve explored other plugins like Calculated Fields Form, wpDataTables. None is as simple as if you can provide a template for adding up points within a record, and across multiple records. Can you provide a template, or recommend how to get help from someone familiar with php and Participant Database?

    Thanks, Ivy

    Plugin Author xnau webdesign

    (@xnau)

    I do have some example code you can work from, you will need to adapt it to your specific needs.

    https://gist.github.com/xnau/1d66ca8e327e1655b32d69578c0e9e0b

    Thread Starter crowwoods1

    (@crowwoods1)

    That sounds good, but it didn’t do anything. My modifications:

    {
      // set this up to list the fields to sum
      // must be numeric!
      $fields_to_total = array('energy_turn_lights_off','energy_unplug_chargers','energy_unplug_small_appliances','energy_reduce_use_of_air_conditioning','energy_reduce_screen_time','energy_turn_off_at_the_power_strip','energy_wash_clothes_in_cold_water','energy_buy_carbon_offsets_for_deliveries','nature_explore_a_nature_walk','nature_play_a_game_outside','nature_hold_a_meeting_outside','nature_weed_without_pesticides','nature_pick_up_trash_in_parks_and_beaches','mobility_use_alternative_transportation','mobility_combine_car_trips','mobility_no_idling','mobility_buy_carbon_offsets','suscom_buy_products_made_locally','suscom_support_local_businesses','suscom_avoid_refined_sugar','suscom_eat_plant_based_diet','suscom_stop_smoking','waste_buy_from_environmentally_responsible_companies','waste_think_twice_before_buying_new_things','waste_avoid_wasting_food','waste_use_reusable_bags','waste_avoid_buying_plastic_or_items_in_plastic_containers','waste_reuse_things_other_than_bags_and_water_bottle','waste_compost_food_waste','waste_zero_waste_for_a_day','waste_no_littering','waste_use_mulch_setting_on_lawnmower','water_take_shorter_showers','water_turn_water_off_when_brushing_teeth','water_run_dishwasher_only_when_full');
      		  
      // name of the total field
      // should be numeric field
      $total_field = 'points_for_daily_actions';
      
      // calculate the total
      $total = 0;
      foreach ( $fields_to_total as $field ) {
        $total += $record[$field];
      }
      
      // place the total in the data array
      $record[$total_field] = $total*10;
    Plugin Author xnau webdesign

    (@xnau)

    Did you install the gist as a plugin and activate it?

    How to Install a WordPress Plugin from a Gist

    Thread Starter crowwoods1

    (@crowwoods1)

    Yes, I followed your instructions. I deactivated the plugin to make changes, then reactivated it to test.

    Thread Starter crowwoods1

    (@crowwoods1)

    Hi Roland,

    I’m really stuck. Is there a way I can hire someone to help me get the Total Fields plugin working? Plus, I would really like to be able to total up team points across multiple records for participants who belong to the same team. Since you don’t have the time, can you recommend someone who can?

    Thanks so much! Ivy

    Plugin Author xnau webdesign

    (@xnau)

    I’m sorry, I don’t have a recommendation to make. I’ve tried to hook up with developers who can do this sort of thing, but it hasn’t worked out.

    One thing you can do to get you there is to use the example code without any modifications just to see it working, then make small changes, checking each time to see if it’s working.

    Thread Starter crowwoods1

    (@crowwoods1)

    well, I did what you said. I re-installed the total-field-handler and it worked. Not instantly as soon as I press ‘Save’, but when I log back in again, it worked.

    Then I changed ‘numeric_1’ to ‘energy_turn_lights_off’ and it didn’t work. Why? Because I have too many underscore in my field name? Too long? So I changed it back to numeric_1, and it no longer worked. Then I deleted the plugin and re-installed it. Still, it wouldn’t work. Now I see that when I reinstalled it, the folder name in my host was a super long string of characters. I’m able to pull it up in the plugin editor, but the function no longer works. Why went wrong? Should I be changing the long string of characters? What to do next?

    Plugin Author xnau webdesign

    (@xnau)

    I don’t know, this sounds like something the server is doing, so you might need to talk to your hosting provider about that folder name.

    As to the rest of it, sounds like a sticky cache that is showing you stale content, not the current content the code is generating. This is a common problem with caches and it’s always best to disable all caching when working on new code so you know you’re looking at what the code is doing, not some cached data that is out of sync.

    Thread Starter crowwoods1

    (@crowwoods1)

    I have renamed the file folder. The long name is what the compressed zip file from gist generated.

    I have disabled the cache in chrome and in wp, but numeric_sum is still not doing the sum. I’m just testing numeric_1 and numeric_2 again.

    Plugin Author xnau webdesign

    (@xnau)

    I’m sorry, it’s almost impossible for me to debug code like this, I don’t have enough information to tell you what is going wrong.

    The code I provide in tutorials is meant to be a starting point for your own custom code. If there is a problem with the code I provided I will fix it, but you are expected to handle customizing it and making it work for your own purposes.

    Thread Starter crowwoods1

    (@crowwoods1)

    I can’t seem to get your code working again. I am not testing any changes I made to your code. Can you test if your code still works?

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Adding Multiple Fields of One Participant’ is closed to new replies.