Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
TR CreditAttribution: TR commentedThere is no such thing as
. You need to access
(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.
Comment #2
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedTR 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
Comment #3
longwaveIt 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.Comment #4
AllyMediaGroup CreditAttribution: AllyMediaGroup commentedlongwave 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.