pdb-before_submit_update
-
Thanks for your plugin!
PDb v1.7.2.1
PDb Field Group Tabs v1.7We are using PDb to support a “Mileage Tracker” for a motorcycle club–something common for bicycle and motorcycle clubs.
Using PDb Field Group Tabs, we created a tabbed form where the first tab is the general member info. Then there are 5 tabs for up to 5 motorcycles that allow the member to enter their year, make, model, starting mileage and ending mileage.
On each of those motorcycle tabs, we also have a read-only “total_miles” field. The main (first) tab has a read-only “total_miles” field that sums up the 5 motorcycle mileage totals.
I created this custom bit to handle this:
/* Mileage Tracking get totals */ function mileage_totals($values) { if (array_key_exists('total_miles', $values)) { $values['bike_1_total_miles'] = intval($values['bike_1_current_end_miles']) - intval($values['bike_1_start_miles']); $values['bike_2_total_miles'] = intval($values['bike_2_current_end_miles']) - intval($values['bike_2_start_miles']); $values['bike_3_total_miles'] = intval($values['bike_3_current_end_miles']) - intval($values['bike_3_start_miles']); $values['bike_4_total_miles'] = intval($values['bike_4_current_end_miles']) - intval($values['bike_4_start_miles']); $values['bike_5_total_miles'] = intval($values['bike_5_current_end_miles']) - intval($values['bike_5_start_miles']); if ($values['bike_1_total_miles'] < 0) { $values['bike_1_total_miles'] = 0; } if ($values['bike_2_total_miles'] < 0) { $values['bike_2_total_miles'] = 0; } if ($values['bike_3_total_miles'] < 0) { $values['bike_3_total_miles'] = 0; } if ($values['bike_4_total_miles'] < 0) { $values['bike_4_total_miles'] = 0; } if ($values['bike_5_total_miles'] < 0) { $values['bike_5_total_miles'] = 0; } $values['total_miles'] = intval($values['bike_1_total_miles']) + intval($values['bike_2_total_miles']) + intval($values['bike_3_total_miles']) + intval($values['bike_4_total_miles']) + intval($values['bike_5_total_miles']); } return $values; } add_action('pdb-before_submit_update', 'mileage_totals'); # Front-end & Admin submissions add_action('pdb-before_submit_add', 'mileage_totals'); # Admin submissions
This custom code is working when we edit a participants form in the admin tool. However, when a member updates their form using the front-end, these fields do not get updated. Is there another hook I need to hook into?
- The topic ‘pdb-before_submit_update’ is closed to new replies.