[Skip to main content](#vessel-content)

#   How to get the Name and e-mail addres in plugin?

##

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

13 years 1 month ago [\#126113](#126113) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126113 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")* was created by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")*

Hi,

I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.

I have this:
Code:

function onAfterOrderUpdate(&amp;$order,&amp;$send_email){ if(!empty($order-&gt;order_id)){ if($order-&gt;order_status == 'confirmed'){ $userClass = hikashop_get('class.user'); $user = $userClass-&gt;get($order-&gt;order_user_id); $username = $user-&gt;username; $email = $user-&gt;email;

but the variables $username and $email are not filled.

Please help.

Kind regards,
Maurice

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

13 years 1 month ago [\#126130](#126130) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126130 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

Hi,

That should work fine, unless you set the "registration" option of the configuration to "no registration" and in that case, no joomla user account is created for the user and thus the values username and email of $user, which come from the joomla user data, won't be filled.

In such case, if you still want to keep your checkout as a "guest checkout", you should take the email address from user_email which is coming from the hikashop user data.
Regarding the name, HikaShop doesn't store any name in the user data. So either you get it from the main address with a call to the getByUser function of class.address of the user, or you do without.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

13 years 1 month ago [\#126175](#126175) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  Replied by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126175 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

Hi Nicolas,

Our registration is set to simplified registration and Joomla accounts are being created.

So I don't understand why the strings $username and $email are empty???
To test it, I send an e-mail to myself from within this function. When an orderstatus changes to confirmed, the email is sent and received, but both strings are empty...

Could there be anything else going on?

Maurice

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

13 years 1 month ago [\#126212](#126212) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126212 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

Hi,

For the code I read, I can't answer you, it looks good.
All I can say is that, if you don't have an email or a username, it means that the HikaShop user which is link to the order does not have an username and an email (so it is not link to a Joomla user).

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

13 years 1 month ago -  13 years 1 month ago [\#126271](#126271) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  Replied by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126271 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

Hi,

When I read what's in $userClass I get this:

hikashopUserClass Object (
[tables] =&gt; Array
(
[0] =&gt; user
)

[pkeys] =&gt; Array
(
[0] =&gt; user_id
)

[namekeys] =&gt; Array
(
)

[_errors:protected] =&gt; Array
(
)

[database] =&gt; JDatabaseMySQL Object
(
[name] =&gt; mysql
[nameQuote:protected] =&gt; &#96;
[nullDate:protected] =&gt; 0000-00-00 00:00:00
[dbMinimum:protected] =&gt; 5.0.4
[_database:JDatabase:private] =&gt; ************
[connection:protected] =&gt; Resource id #32
[count:protected] =&gt; 0
[cursor:protected] =&gt; Resource id #241
[debug:protected] =&gt;
[limit:protected] =&gt; 0
[log:protected] =&gt; Array
(
)

[offset:protected] =&gt; 0
[sql:protected] =&gt; SELECT a.*,b.* FROM #__hikashop_user AS a LEFT JOIN #__users AS b ON a.user_cms_id=b.id WHERE a.user_id=0
[tablePrefix:protected] =&gt; *****_
[utf:protected] =&gt; 1
[errorNum:protected] =&gt; 0
[errorMsg:protected] =&gt;
[hasQuoted:protected] =&gt;
[quoted:protected] =&gt; Array
(
)

)

)

I'm not sure what this means, but it looks empty. The user is 100% absolutely in the joomla user list and has an e-mail address.
Any other ideas how I can troubleshoot this?

Maurice

P.S.: this is the complete file content:
Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.1.3 * @author hikashop.com * @copyright (C) 2010-2013 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php class plgHikashopInterspire extends JPlugin { function plgHikashopInterspire(&amp;$subject, $config){ parent::__construct($subject, $config); if(!isset($this-&gt;params)){ $plugin = JPluginHelper::getPlugin('hikashop', 'history'); if(version_compare(JVERSION,'2.5','&lt;')){ jimport('joomla.html.parameter'); $this-&gt;params = new JParameter($plugin-&gt;params); } else { $this-&gt;params = new JRegistry($plugin-&gt;params); } } } function onAfterOrderCreate(&amp;$order,&amp;$send_email){ return $this-&gt;onAfterOrderUpdate($order,$send_email); } function onAfterOrderUpdate(&amp;$order,&amp;$send_email){ if(!empty($order-&gt;order_id)){ if($order-&gt;order_status == 'confirmed'){ $userClass = hikashop_get('class.user'); $user = $userClass-&gt;get($order-&gt;order_user_id); $name = $user-&gt;username; $mail = $user-&gt;email; // Testing $results = print_r($userClass, true); // Test e-mail $to = 'mailservice@****.nl'; $subject = 'A user has been added to the FollowUp list'; $headers = 'From: info@****.nl' . "\r\n" . 'Reply-To: info@****.nl' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $message .= "Results Array: $results \r\n" ; $message .= "Name: $name \r\n" ; $message .= "Email: $mail" ; mail($to, $subject, $message, $headers); } } return true; } }

Last edit: 13 years 1 month ago by [Maurice](/forum/user/7972-maurice "View Maurice's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

13 years 1 month ago [\#126272](#126272) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126272 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

$user no $userClass

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Maurice](/forum/user/7972-maurice "View Maurice's Profile")**
- [![Maurice's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/7972-maurice "View Maurice's Profile") Topic Author
- [ Offline](/forum/user/7972-maurice)

Less More

- Posts: 151
- Thank you received: 9
-
-

13 years 1 month ago [\#126274](#126274) by [Maurice](/forum/user/7972-maurice "View Maurice's Profile")  Replied by *[Maurice](/forum/user/7972-maurice "View Maurice's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126274 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

When I do:
Code:

$results = print_r($user, true);

$results is empty.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

13 years 1 month ago [\#126316](#126316) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[How to get the Name and e-mail addres in plugin?](/forum/4-how-to/862511-how-to-get-the-name-and-e-mail-addres-in-plugin#126316 "Hi,  I created a plugin and now I need to get the user NAME and EMAIL address to send it via cURL to our external list server.  I have this:  but the variables $username and $email are not filled.  Please help.  Kind regards, Maurice")*

Hi,

The code seem to be correct, thanks to set the Joomla error reporting to maximum to see if an error is returned.
And thanks to check if the id given in "order_user_id" exist in the database via phpMyAdmin.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzQtaG93LXRvLzg2MjUxMS1ob3ctdG8tZ2V0LXRoZS1uYW1lLWFuZC1lLW1haWwtYWRkcmVzLWluLXBsdWdpbj90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.079 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
