PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Calculating Averages

  1. Hi Guys,

    Further to this thread:
    http://www.gravityhelp.com/forums/topic/mathematics-to-gravity-forms

    We've got a review form where users post scores for particular criteria, these are radio buttons with values between 1 and 10. There are 8 of these with titles like Management Style and Remuneration etc.

    This is the form:
    http://www.jobinsider.com.au/new-review-form

    Once the reviews have been approved (post status changed from Draft to Published) by a moderator the results are published into a post that's attached to that company. I'd like to calculate the average score of those 8 fields and include the score in the published results.

    This is an example of the published result:
    http://www.jobinsider.com.au/fictional-company

    I'm no great shakes at PHP but I do have a developer helping us out who can help implement.

    Appreciate any help you can provide.

    Posted 12 years ago on Thursday September 15, 2011 | Permalink
  2. What you would need to do is add a hidden field to your form that will hold the result.

    Then you would write custom PHP to use a Gravity Forms hook to read the fields you are using for scoring, calculate the result, and store it in this hidden field.

    If you are using Gravity Forms v1.6 which is currently in beta you would use this hook:

    http://www.gravityhelp.com/documentation/page/Gform_after_submission

    If you are using an older version of Gravity Forms you would use this hook:

    http://www.gravityhelp.com/documentation/page/Gform_post_submission

    I recommend using Gravity Forms v1.6 as the new hook is replacing the old one as the ideal hook to use for this type of customization.

    Your custom code would either go in your themes functions.php file or you could create your own custom plugin that you would then activate.

    Posted 12 years ago on Thursday September 15, 2011 | Permalink