• Resolved viperboys

    (@viperboys)


    Hi, I work with Gravity Form and Gravity Flow. When Gravity Flow has some advanced fields called multi-user. When you print this field the user ID appears and should display the user’s name.

    How can I achieve this?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Hi there,

    I was testing this out in my local development environment, but was not able to replicate this issue when using a Core Gravity PDF template. The PDF correctly displayed the selected user’s names, just like Gravity Forms does on the Entry Details page.

    How are you outputting the Multi User field to the PDF? Have you built a custom PDF template and are using the $form_data array? Or are you doing something different?

    Thread Starter viperboys

    (@viperboys)

    Hi,

    Yes, I am making a custom template.

    This is the code

    <?php
    
    /*
    * Template Name: Acta Reunion Comite
    * Version: 2.4
    * Description: A custom PDF template designed specifically for the "Badshahweb" Gravity Form.
    * Author: Gravity PDF
    * Author URI: https://gravitypdf.com
    * Group: Acta Reunion Comite
    * Required PDF Version: 4.0-alpha
    */
    
    /* Prevent direct access to the template */
    if ( ! class_exists( 'GFForms' ) ) {
        return;
    }
    
    /*
    * All Gravity PDF 4.x templates have access to the following variables:
    *
    * $form (The current Gravity Form array)
    * $entry (The raw entry data)
    * $form_data (The processed entry data stored in an array)
    * $settings (the current PDF configuration)
    * $fields (an array of Gravity Form fields which can be accessed with their ID number)
    * $config (The initialised template config class – eg. /config/zadani.php)
    * $gfpdf (the main Gravity PDF object containing all our helper classes)
    * $args (contains an array of all variables - the ones being described right now - passed to the template)
    */
    
    $f = function( $fid, $newline = true ) use ( $form_data, $fields ) {
        if ( $newline ) {
            echo '  ';
        }
    
        switch ( $fields[ $fid ]['type'] ) {
    
            case 'address':
                $data = $form_data['field'][ $fid ];
    
                $line   = [];
                $line[] = $data['street'];
                $line[] = $data['street2'];
                $line[] = implode( ', ', array_filter( [ $data['city'], $data['state'] ] ) ) . ' ' . $data['zip'];
                $line[] = $data['country'];
                echo implode( '<br>', array_filter( $line ) );
            break;
    
            case 'fileupload':
                $file = $form_data['field'][ $fid ][0];
                if ( strlen( $file ) > 0 ) {
                    echo '<a href="' . $file . '">Download File</a>';
                }
            break;
    
            default:
                echo $form_data['field'][ $fid ];
        }
    
    };
    
    ?>
    <style>
    @page {
            header: html_pageHeader;
            footer: html_pageFooter;
            margin: 0mm 10mm;
        }
    
        p {
            margin: 0 0 27  mm;
            padding: 0;
        }
    
        a {
            color: blue;
        }
    
        /* Header / Footer */
        header {
            text-align: center;
            padding-bottom: 6mm;
        }
    
        footer {
            text-align: center;
        }
    
        /* Heading */
        h3 {
            margin: 0;
            padding: 2mm 0;
            font-size: 100%;
        }
    
        /* Tables */
        egt {
            border: 1px ;
            padding: 1.5mm;
            vertical-align: middle;
        }
    
        table {
            margin: 3mm 1mm;
    
        }
    
        th {
            text-align: left;
        }
    
        td {
            border: 1px solid #c3c3c3;
            padding: 1.5mm;
            vertical-align: middle;
        }
    
        .no-border td {
            *border: none;
            padding: 0;
        }
    
    thead tr td{
    text-align:left;
     font-weight:bold;
     font-size:15px;
    }
    tbody tr td, .top-finel_row table tr td{
    text-align:left;
    }
    
    span{
     font-weight:bold;
    }
    
    .column {
      float: left;
      width: 23%;
    
    }
    .column2 {
      float: left;
      width: 50%;
      }
    
    .column1 {
      float: left;
      width: 100%;
      }
    
    /* Clear floats after the columns */
    .row:after {
      content: "";
      display: table;
      clear: both;
    }
    
    </style>
    
    <!-- Begin HTML -->
    <htmlpageheader name="pageHeader">
        <header>
    
                <span color="#f26721">G4 INGENIEROS CIVILES S.A.S CIVILES S.A.S<br>
                NIT: 900.181.427 - 1<br>
                F-AD-011<br></span>
    
                <div align="right" style="position: absolute; margin-top: -55px"><img width="10%" src="<?php echo _DIR_; ?>/images/logocompleto(1).png"></div>
    
                    <table>
                <tr>
                    <td><span color="#f26721" style="font-size: 13px">Versión. 1 <br> Sept 24/2019</span></td>
                    <td align= "center"><span color="black" style="font-size: 13px">ACTA REUNIóN COMITé</span></td>
                    <td><span color="#f26721" style="font-size: 13px">Página {PAGENO} de 2</span></td>
                </tr>
            </table>
    
        </header>
    </htmlpageheader>
    
    <htmlpagefooter name="pageFooter">
        <footer>
    
        </footer>
    </htmlpagefooter>
    
    <table>
        <tr>
            <td bgcolor= "#ebebeb">EMPRESA</td>
            <td><?php $f( 7 ); ?></td>
            <td WIDTH="180" bgcolor= "#ebebeb">FECHA</td>
            <td><?php $f( 1 ); ?></td>
        </tr>
        <tr>
            <td bgcolor= "#ebebeb">HORA INICIO</td>
            <td><?php $f( 9 ); ?></td>
            <td bgcolor= "#ebebeb">HORA FIN</td>
            <td><?php $f( 10 ); ?></td>
        </tr>
        <tr>
            <td bgcolor= "#ebebeb">LUGAR</td>
            <td><?php $f( 8 ); ?></td>
            <td bgcolor= "#ebebeb">ID COMITé</td>
            <td><?php $f( 152 ); ?>12</td>
        </tr>
    
    </table>
    
    <p>1. ASISTENTES INTERNOS</p>
    
    <?php echo ( 28 ); ?>
    
    <!–<p>2. ASISTENTES EXTERNOS</p>
    <table>
        <tr>
           <td>
               <?php
                           $value= $form_data['field'][31];
    
                           if ($value=='1'){
                            $f( 28 );
                           } else {
                           echo "NO APLICA";
                           }
                ?>
           </td>
        </tr>
        <tr>
            <td>
                <?php
                           $value= $form_data['field'][31];
    
                           if ($value=='2'){
                            $f( 29 );
                           } else {
                           echo 'NO APLICA';
                           }
                ?>
    
            </td>
        </tr>
        <tr>
            <td>
                <?php
                           $value= $form_data['field'][31];
    
                           if ($value=='3'){
                            $f( 30 );
                           } else {
                           echo 'NO APLICA';
                           }
                ?>
    
            </td>
        </tr>
    </table>
    
    <p>3. OBJETIVO DEL COMITé</p>
    <table>
        <tr>
           <td><?php $f( 5 ); ?></td>
        </tr>
    </table>
    
    <p>4. DESARROLLO DE LA REUNIóN</p>
    <table>
        <tr>
           <td><?php $f( 18 ); ?></td>
        </tr>
    </table>
    
    <p>5. TAREAS ASIGNADAS</p>
    <?php echo "{all_fields:exclude[7,8,1,9,10,11,31,28,13,29,26,30,27,5,18]:gpnf_table}" ?>–>

    I print the field like this

    <?php $f( 5 ); ?>

    <?php $value= $form_data[‘field’][11]; echo $value;?>

    Either way just prints the user id.

    Plugin Author Jake Jackson

    (@blue-liquid-designs)

    Thanks for clarifying. The easiest solution would be to use the associated Merge Tag for that specific field in your custom template. You’ll get the user’s names output in a comma-separated list that way.

    If you really want to get that information using the $form_data array, you would need to parse the results of $form_data[‘field’][11] and then look up the user account and output the name manually.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to display a multiuser type field – Gravity Flow’ is closed to new replies.