How to add user's information in the certificate?

How to add user's information in the certificate?

by Alexandre do Vale -
Number of replies: 1

Hi (:


I created a new field in the user form (in Other files) called RG and now want to add to the certificate.

I don't know where should I start modifying. The table where the RG is being stored is called "mdl_user_info_data" and "date" column.

Does anyone have any tips or tutorial on how to add this information in the certificates?


Best regards,

Alexandre do Vale

Average of ratings: -
In reply to Alexandre do Vale

Svar: How to add user's information in the certificate?

by David Bennett -

Hi Alexandre,

This is perhaps a bit late for your needs...

This is based on code that worked for me in 2.7 (changed to reflect your table and column)

In certificate.php add


$myid = $USER->id; // to identify the user in question

$value = $DB->get_record_sql('SELECT * FROM {user_info_data} WHERE id = ?', array($myid)); //query the db

if ($value) {

       $value = $value->date; // choose the date column from the $value db answer

} else {

        $value = '';

}

$textToDisplay = "This is from the date column: " . $value;  // build a text string to be displayed



certificate_print_text($pdf, $x, $y + 258, 'C', 'Helvetica', '', 14, $textToDisplay); //add the custom text. change the positioning and text size to suit

Hope this helps

David