Filter last registered user only

  • Posts: 10
  • Thank you received: 0
2 years 2 weeks ago #346253

-- HikaShop version -- : 4.6.2
-- Joomla version -- : 3.10.11

Hi,

I wanted to find out how we can target the last registered user only, so that I can trigger an email etc. I already have it working so that the user is moved into the correct group when the user registers but I also want some extra actions taken depending on which group they are added to.

I need the mass action to only look at the last registered user specifically. How do I create a filter to do that?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 2 weeks ago #346257

Hi,

Could you tell us more about your goals ?
An email is already sent to the customer after his registration. This email named "user account" can be customized in the System>Emails menu.
Similarly, if you activate the admin notification email in the Joomla user manager, the admin will also receive an email. It will probably be easier to customize these emails than adding extra filters/actions to the mass actions system.

Also, to do filters/actions for the last registered user, you can just use the "after a user is create" trigger in your mass action. That way, the actions of your mass action will automatically trigger after a user registers.

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

  • Posts: 10
  • Thank you received: 0
2 years 5 days ago #346620

Hi,

Sure, we need to split users into 2 groups; retail and wholesale. The retail accounts could be allow to self activate but the wholesale accounts should require admin approval.

I wanted to have a cron disable the user account immediately if they select wholesale and then send an email to admins to check and approve the account manually.

I tried to use the 'after a user is created' trigger (which works fine) but I need to filter just the last account that are in the wholesale group only, not all. I couldn't see how to only filter for the last created account etc.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 5 days ago #346623

Hi,

If you're using a trigger, only the element(s) which triggers the event will be taken into account.
So you don't need any filter to do that. It should already work like you want.

Last edit: 2 years 5 days ago by nicolas.

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

  • Posts: 10
  • Thank you received: 0
2 years 4 days ago #346667

Hi,

Ok I think I still need to filter to check if the user registered for wholesale or retail (which I can do) but when I test the mass action to 'display the results' it shows all users in the wholesale group in the table. I would hate to deactivate all wholesale users every time someone registers.

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 4 days ago #346674

Hi,

Indeed, if you run the mass action manually, it will work on all the elements.
If you want to test the mass action in real conditions, just create new user accounts from the frontend and you'll see it will work only on the new user.
Now if you don't believe me, just run a "export a CSV file" action with the "after a user is created" trigger and you'll see you'll get a CSV file with only the new user data in the path where you configured it to be generated.

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

  • Posts: 10
  • Thank you received: 0
2 years 11 hours ago #346749

Hi,

Yep that helped me a lot to see whats going on thanks. However I've hit one last issue with this.

I am outputting a xls file for testing as you said and in that I'm looking for a custom user field 'acc_type'. This field is working correctly as I can go into the user page in the backend of the website and see the field with the user selected value. BUT the xls file, shows a blank field. This field was meant to be used for the user to select retail or wholesale and I only need to tack action on the wholesale users.

So why is the database getting the custom field data but the mass action can't see it?

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 7 hours ago #346757

Hi,

Thanks for the details. So I looked into it and I have the same behavior on my end.
HikaShop has a user synchronization plugin, which has, among other things, the capability to add the user in HikaShop when a user is created from Joomla or from another extension. And since the HikaShop registration process adds the Joomla user before it then adds the HikaShop user (so that it can user the id of the Joomla user in the HikaShop user entry as reference), the user synchronization plugin would add the user in HikaShop while Joomla would add the user in Joomla, undercutting the registration process.
This would usually not be a problem since it just means that the saving done by the registration process for the HikaShop user data would end up as an update, and not a creation.
So that's why your mass action would be empty. The "after a user is created" event would actually be before the user data would be saved by the registration process.
So I've made a patch to the mechanism so that the user synchronization plugin will skip the synchronization if the Joomla user creation happens from HikaShop's registration process. It then now properly triggers the "after a user is created" and not the "after a user is updated" when saving the HikaShop user data in the database during the registration process.
To get the patch, download the install package of HikaShop on our website and install it on your website and that mass action should then work fine, like it does on my end.

The following user(s) said Thank You: Adnohr

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

Time to create page: 0.073 seconds
Powered by Kunena Forum