Skip to Content Skip to Menu

Auto Action query doesn't update username

  • apdt
  • apdt
  • OFFLINE
  • Posts: 92
  • Thanks: 2
  • Karma: 3
12 years 2 months ago - 12 years 2 months ago #207958 by apdt
Last time I was using CB Queries to generate numeric member ID which is then assigned to the username upon member approval by admin. Now I move the SQLs to CB Auto Action and it doesn't work anymore.

Here is how I set up the Auto Action:
Type: Query
Triggers: onBeforeUserApproval
User: Automatic
Access: Everybody
Query:
Code:
UPDATE `#__users` SET `username` = (SELECT `next_memberid` FROM `#__apdt_memberid_counter` LIMIT 1) WHERE `id` = '[user_id]'; UPDATE `#__comprofiler` SET `cb_memberid` = (SELECT `next_memberid` FROM `#__apdt_memberid_counter` LIMIT 1) WHERE `user_id` = '[user_id]'; UPDATE `#__apdt_memberid_counter` SET `next_memberid` = `next_memberid` + 1;

What happens is query #2 (updating jos_comprofiler) and #3 (incrementing the counter) work, only the one updating jos_users doesn't work. I tried to run the query directly in phpMyAdmin and it works.

I have another Auto Action query that updates username to email address but the trigger is onAfterUserRegistration,onAfterNewUser and it executes without problem during registration.

Any idea why only that particular query #1 doesn't work?

Joomla 1.5.26
CB 1.8.1
CBSubs 2.0.2
Last edit: 12 years 2 months ago by apdt.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
12 years 2 months ago #207972 by krileon
Replied by krileon on topic Re: Auto Action query doesn't update username
You're using an on before trigger. A user store is done directly after that. The user store will update _comprofiler and _users. Query actions don't touch user object. This means your query changes will be overridden by the user object store, which still has the old information. Use a field action to properly adjust values such as that or change to a more appropriate trigger.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • apdt
  • apdt
  • OFFLINE
  • Posts: 92
  • Thanks: 2
  • Karma: 3
12 years 2 months ago #207977 by apdt

krileon wrote: You're using an on before trigger. A user store is done directly after that. The user store will update _comprofiler and _users. Query actions don't touch user object. This means your query changes will be overridden by the user object store, which still has the old information.

Is this the case for all onBefore___ triggers? Meaning if I want to modify _users or _comprofiler tables I can't use onBefore___ triggers?

krileon wrote: Use a field action to properly adjust values such as that

How do I get value from custom table? The counter is stored in a custom table `jos_apdt_memberid_counter.next_memberid`.

Field = Member ID (this corresponds to jos_comprofiler.cb_memberid)
Operator = Set (Field = Value)
Value = ???

krileon wrote: or change to a more appropriate trigger.

I need to send the Member ID in the welcome/approval email so which other triggers are fired during approval? The logic is that Member ID is only generated for approved members so I can't put it in before/after registration triggers.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
12 years 2 months ago #207987 by krileon
Replied by krileon on topic Re: Auto Action query doesn't update username

Is this the case for all onBefore___ triggers? Meaning if I want to modify _users or _comprofiler tables I can't use onBefore___ triggers?

It depends entirely on the location and as to what happens after the on before trigger. If there's a user store, before a page load, directly after the trigger then yes queries that alter _users and _comprofiler won't work right and you need to use a Field action.

How do I get value from custom table? The counter is stored in a custom table

Could use a CB Query Field to retrieve the value then use that query field as a substitution in the field action "Value: [cb_myquery]".

I need to send the Member ID in the welcome/approval email so which other triggers are fired during approval? The logic is that Member ID is only generated for approved members so I can't put it in before/after registration triggers.

Just use the after approval trigger as follows.

onAfterUserApproval


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • apdt
  • apdt
  • OFFLINE
  • Posts: 92
  • Thanks: 2
  • Karma: 3
12 years 2 months ago #208025 by apdt

krileon wrote: Could use a CB Query Field to retrieve the value then use that query field as a substitution in the field action "Value: [cb_myquery]".

Thanks! I got it to work BUT I have to use onBeforeUserBlocking trigger.

Here is my finding. With Auto Action field, I need to create 2 actions - one to set 'cb_memberid' field to the next available ID (the CB Query Field) and the other to update the username to the member ID.

If I use onBeforeUserApproval, the 'Username' within [DETAILS] substitution tag shows the correct numeric Member ID in the Welcome email but using [username] tag in the same Welcome email returns blank. Looks like [DETAILS] and [username] are pulling data from different locations.

So approving member needs 2 steps
1) Click the 'X' under 'Blocked' column to generate the Member ID
2) Click the clock icon under 'Approved' column to send out the Welcome email

Just use the after approval trigger as follows.

onAfterUserApproval


Nope, doesn't work because the Welcome email is sent before all fields are updated and therefore either the Member ID or Username will be incorrect in the email.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
12 years 2 months ago #208039 by krileon
Replied by krileon on topic Re: Auto Action query doesn't update username
I recommend using the after registration trigger then. This way their information is changed and accurate directly after registering.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

Moderators: beatnantkrileon
Powered by Kunena Forum