I’m using a Participant Database template (a plugin for WordPress) to write out a record for people signing up for the Earth Day Challenge. The basic template works fine, except I want to get it to add up points based on whether people check off a one-time action, and indicate the no. of days they do a daily action during the Challenge. There are about 50 possible actions, so doing it manually is a bit time consuming.
I can’t seem to get it to work, i.e. syntax errors. I have no access to the parent code. Here’s what I have. Anything that mentions Points is my addition. Thanks!
<div class="wrap <?php echo $this->wrap_class ?>">
<?php
/*
* as of version 1.6 this template can handle the display when no record is found
*
*
*/
if ( !empty( $this->participant_id ) ) :
?>
<?php // output any validation errors
$this->print_errors();
?>
<?php
// print the form header
$this->print_form_head()
?>
<?php
// initialize the points
$calc_points_one_time_actions=0; ?>
<?php $calc_points_daily_actions=0; ?>
<?php while ( $this->have_groups() ) : $this->the_group(); ?>
<?php $this->group->print_title() ?>
<?php $this->group->print_description() ?>
<table class="form-table">
<tbody class="field-group field-group-<?php echo $this->group->name ?>">
<?php
// step through the fields in the current group
while ( $this->have_fields() ) : $this->the_field();
?>
<tr class="<?php $this->field->print_element_class() ?>">
<?php if ( $this->group()==$points && $this->field()==$this->field->points_for_one_time_actions) : ?> {
<tr>
<th for="<?php $this->field->print_element_id() ?>"><?php $this->field->print_label() ?></th>
<td>
<?php> $this->field->points_for_one_time_actions = $calc_points_one_time_actions; ?>
<?php> $this->field->print_points_for_one_time_actions() ?>
</td>
</tr>
}
<?php elseif ($this->group()==$points && $this->field()==$this->field->points_for_daily_actions) : ?> {
<tr>
<th for="<?php $this->field->print_element_id() ?>"><?php $this->field->print_label() ?></th>
<td>
<?php> $this->field->points_for_daily_actions = points_for_daily_actions; ?>
<?php> $this->field->print_points_for_daily_actions() ?>
</td>
</tr>
}
<?php elseif ($this->group()==$points && $this->field()==$this->field->total_points) : ?> {
<tr>
<th for="<?php $this->field->print_element_id() ?>"><?php $this->field->print_label() ?></th>
<td>
<?php> $this->field->total_points = $this->field->points_for_one_time_actions + $this->field->points_for_daily_actions; ?>
<?php> $this->field->print_total_points() ?>
</td>
</tr>
}
<?php else : ?>
<tr>
<th for="<?php $this->field->print_element_id() ?>"><?php $this->field->print_label() ?></th>
<td>
<?php $this->field->print_element_with_id(); ?>
<?php if ( $this->field->has_help_text() ) : ?>
<span class="helptext"><?php $this->field->print_help_text() ?></span>
<?php endif ?>
</td>
</tr>
<?php endif ?>
<tr>
<td>
<?php if( $this->group()==$one_time_activities && $this->field->value()==("Completed")) {
$calc_points_one_time_actions = $calc_points_one_time_actions + 25; }
?>
<?php if( $this->group()==$daily_activities)
$calc_points_daily_actions = $calc_points_daily_actions + ($this->field->value() * 10);
?>
</td>
</tr>
<?php endwhile; // field loop ?>
</tbody>
</table>
<?php endwhile; // group loop ?>
<table class="form-table">
<tbody class="field-group field-group-submit">
<tr>
<th><h3>
<?php $this->print_save_changes_label() ?>
</h3></th>
<td class="submit-buttons">
<?php $this->print_submit_button( 'button-primary' ); // you can specify a class for the button, second parameter sets button text ?>
</td>
</tr>
</tbody>
</table><!-- end group -->
<?php $this->print_form_close() ?>
<?php else : ?>
<?php $error_message = Participants_Db::plugin_setting( 'no_record_error_message', '' );
if ( !empty( $error_message ) ) :
?>
<p class="alert alert-error"><?php echo $error_message ?></p>
<?php endif ?>
<?php endif ?>
</div>