profile_* are missing from $accounts object

tassoman - October 21, 2007 - 14:28
Project:PDF-IDcard
Version:5.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:jredding
Status:closed
Description

The data contained into profiles isn't included into $account object.

#1

jredding - October 21, 2007 - 15:04
Category:bug report» feature request
Assigned to:Anonymous» jredding

ya.. the $account object is a return from user_load which doesn't load the profile fields from the profile module. Although this isn't really a bug because the profile module is a separate module. I'm changing this to a feature request.

I can update the module so that it checks for the existence of the profile module and then does a profile_load_profile to populate the $account object.

In the meantime you can do this in your PHP code

profile_load_profile($account);

Here is an example of it in use. This is bit of badge code that I whipped up for a client. The X,Ys, of course, depend on the image used as the background

//Load the profile fields
profile_load_profile($account);

//print horizontal first name
$pdf->SetFont('freemono', '', 60);
$pdf->setxy(52,178);
$pdf->SetTextColor(100,100,100);
$pdf->Cell(10,40,strtoupper($account->profile_firstname),0,0,"left",0,0);

//print horizontal last name
$pdf->SetFont('freemono', '', 65);
$pdf->setxy(52,192);
$pdf->SetTextColor(255,0,0);
$pdf->Cell(10,40,strtoupper($account->profile_lastname),0,0,"left",0,0);

//Print expirydate exactly one year from date printed.
$pdf->SetFont('freemono', 'b', 20);
$pdf->setxy(79,202);
$pdf->SetTextColor(0,0,0);
$expirydate = date('n/j/Y', mktime(0, 0, 0, date("m"),   date("d"),   date("Y")+1));
$pdf->Cell(10,40,$expirydate,0,0,"left",0,0);

//Print vertical firstname
$pdf->SetFont('freemono', '', 40);
$pdf->Rotate(-90, 270, 0);
$pdf->setxy(321,9);
$pdf->SetTextColor(100,100,100);
$pdf->Write(10,strtoupper($account->profile_firstname), NULL, 0);

//Print vertical lastname
$pdf->SetTextColor(240,0,0);
$pdf->SetFont('freemono', '', 45);
$pdf->Write(10,strtoupper($account->profile_lastname), NULL, 0);

#2

tassoman - October 21, 2007 - 15:08

I have updates... Looking at users ID cards, some of them were correctly filled with $account->profile_realname and some other not filled.

Sometimes i get three errors also:

warning: Cannot modify header information - headers already sent by (output started at /home/tassoman/drupal/sites/all/modules/PDF-IDcard/tcpdf/tcpdf.php:2532) in /home/tassoman/drupal/sites/all/modules/PDF-IDcard/tcpdf/tcpdf.php on line 2525.

I'll explicit force the loading of profile module...

#3

jredding - October 21, 2007 - 15:24

unless you do a profile_load_profile($account) they should never have any profile fields on the $account. This hasn't nothing to do with this module just how the profile module works. When doing a user_load the profile module doesn't hook into that, you have to explicitly do a profile_load_profile($user) to get the profile fields.

I find it odd that it was work for some accounts though.. very odd.

In regards to the header already sent error. If this is happening often can you try to determine when it is happening so that I can duplicate the error. Is it on a particular user or users in a role, etc. etc.

Finally please open a separate ticket for the "Header already sent error" if its recurring. This way I, you and everyone else can track the issues separately (and close as necessary once they have been fixed).

#4

jredding - October 21, 2007 - 16:15
Status:active» fixed

feature added into CVS, will be in version 5.1.2

#5

Anonymous - November 12, 2007 - 22:42
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.