Jump to content

Custom PIREP field to appear in Pilot Center or Custom Profile Field to appear in PIREP!

Recommended Posts


I've added a custom PIREP field so my pilots can record the number of points they get following each flight however I'm not sure how to display this in the Pilot Center as part of their profiles...any ideas?
I've tried the Custom Profile Field option however this doesnt appear on the PIREP so not quite what I'm looking for :-)

Any help is appreciated!

Share this post

Link to post
Share on other sites

Hmmm, what you request is not that easy because it may require a few work to be done. Open the core/common/PIREPData.class.php file and find this:

public static function deleteField($id) {
        $sql = 'DELETE FROM ' . TABLE_PREFIX . 'pirepfields WHERE fieldid=' . $id;

        $res = DB::query($sql);

        if (DB::errno() != 0) return false;

        return true;

        //TODO: delete all of the field values!
        //$sql = 'DELETE FROM '.TABLE_PREFIX.'

after this, add the following part of code:

public static function getSumByField($pilotid, $field) {
    $sql = "SELECT SUM(v.value) AS total FROM ".TABLE_PREFIX."pirepvalues AS v LEFT JOIN ".TABLE_PREFIX."pireps AS p ON p.pirepid=v.pirepid WHERE v.fieldid='$field' AND p.pilotid='$pilotid' AND v.value REGEXP '^[0-9]+$'";
    $total = DB::get_row($sql);
    if(!$total) return 0;
    return $total->total;

Then within the pilot's center or any other part of your website, you can use the following code to show the total points. Just ensure that the pilot really submits numbers within the points section although I added an extra check within the where statement.


Do not forget to update the SET_HERE_THE_PILOT_ID and SET_HERE_THE_FIELD_ID values accordingly. I did not test it but it should work. Let me know if it does.


phpVMS Modules | Web Hosting | Pilot Awards (w/Auto Awards) | Pilot Shop | Real Booking System | Forum System

Share this post

Link to post
Share on other sites

Hi @servetas

I've added your code to the core/common/PIREPData.class.php however when I add the following line to profile_main.php, I can see the name of the field but no values within?

  • Grade: 4
  • Violations: 68
  • Latest XP: 

Here is what I added in profile_main.php

<li><strong>Latest XP: </strong><?php echo PIREPData::getSumByField($pilotid, $field); ?></li>

Any help would be appreciated!



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now