I am needing to print the role of the customer that made the invoice. What I did was add to the email address area this code

<b><?php echo t('E-mail Address:'); ?></b><br />
<b><?php echo t('User Name'); ?></b><br />
<b><?php echo t('User Role'); ?></b>
                </td>
                <td width="98%">
<?php echo $order_email; ?><br />
<?php $customer = user_load($order->uid); print $customer->name; ?><br />
<?php $customer = user_load($order->uid); print $customer->role; ?>

Everything works but the printing of the role. I think I have got to be close, but who knows it could be way off. Any help is much appreciated.

Comments

TR’s picture

Priority: Major » Normal
Status: Active » Fixed

There is no such thing as

$customer->role

. You need to access

$customer->roles

(note the 's'), which will be an array of roles that the user has. Each element has an index of rid and a value of role name.

AllyMediaGroup’s picture

TR thank you for the quick response. I have changed that to $customer->roles and I get a return of

User Role: Array

on the print for invoice. That is where I am stuck, how do I get the role of the user to show. This would be for different roles showing for each customer. The roles are like medical, high school, Physics. Each customer has a specific role for their specific catalog. If I specify the rid then I would assume that you would get the same for each customer.

Thanks for the help

longwave’s picture

It is an array, because a customer can have more than one role. Something like print implode(', ', $customer->roles); will print all roles in a comma-separated list.

AllyMediaGroup’s picture

longwave you are awesome, pulled the information that I needed. Is there a way to remove a specific role from the print.

It prints the authenticated user role and I don't need that to show on the invoices.

Status: Fixed » Closed (fixed)

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