Plugin that implements onUserAfterSave not firing

  • Posts: 28
  • Thank you received: 3
1 week 8 hours ago #366782

-- HikaShop version -- : 5.1.5
-- Joomla version -- : 4.4.13
-- PHP version -- : 8.1.32

Hello,
I (vibe)coded a plugin to update my Mailchimp contacts with a new tag. My intention was that if they purchase on my site using Hikashop, they get tagged as a client.
The plugin implements the onUserAfterSave event and works if I save the user using the com_users component.
But the plugin won't fire after Hikashop creates a new user on my site, for instance during the order process.
My understanding is that Hikashop implements its own user API with onAfterUserCreate(&$element)
Does this mean I need to explicitly call this function in my plugin, if I want full integration with Hikashop?
Thanks in advance,
Brett

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
6 days 18 hours ago #366785

Hi,

Please note that we developed a plugin to do exactly this and released it a bit more than 1 month ago. It's available on our marketplace here:
www.hikashop.com/marketplace/product/288...-with-mailchimp.html
This might be an easy solution for you instead of developing something from scratch.

And yes, onUserAfterSave is a Joomla event. So, if you save a user in HikaShop that event won't be called because HikaShop is not modified the Joomla user information. Only the HikaShop user information is modified.
So you would need to implement the onAfterUserCreate event so that your plugin is called when a user is saved in HikaShop, if that's what you need.

Please Log in or Create an account to join the conversation.

  • Posts: 28
  • Thank you received: 3
5 days 6 hours ago #366821

Hi Nicolas,
Please forgive me if I have misunderstood.
My checkout process involves only two steps. The first step is register/create an account.
Once the user completes the form and creates a new account, this is when I intend for my mailchimp synchronization plugin to fire.
The second step involves the rest of the checkout process (cart, payment). This is when the orders are created and, I presume, when your plugin would fire. Is this correct, or would your Integration plugin also run before any order were created or confirmed?
Finally, I've activated the Hikashopuser plugin, which appears to also listen for the onUserAfterSave event. Could this be somehow blocking the event from reaching my plugin?
Thanks in advance,
Brett

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
4 days 18 hours ago #366823

Hi,

Our plugin indeed fires only when the order is created or payment. If you need to send data of registrations to Mailchimp then this is not the purchase of this plugin. Other plugins, already available out there are already able to do that, and that's why we focused on the order creation / confirmation.

The way events work in Joomla (and how an "event pattern" usually works) is that different plugins can register to different events and when something triggers and event, all the plugins registered to the event will be called.
So, the fact that other plugins implement onUserAfterSave has no incidence on your plugin being called or not.

Note that onUserAfterSave is an event of the Joomla "user" group of plugins. Only plugins of the group "user" or of the group "system" (which are always loaded on all the pages and can register any event) are guaranteed to be triggered for it. If you created a plugin of the group "hikashop", then he might or might not be called based on whether HikaShop loaded the plugins of the "hikashop" group during the processing of the request.

The following user(s) said Thank You: brettv

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum