Skip to Content Skip to Menu

Auto Action: only onAfterLogout working?

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
7 years 6 months ago #293162 by MMDoege
Hello,

I have a quite simpls use case where a field has to be set to specific value by an Auto Action:

Trigger: onAfterLogout
Condition: 1 EQUAL 1
Action:
Field: cb_language_tag
Operator: Set (field = value)
Value: [cb:config param="lang_tag" /]
Translate Value: Yes

Actually this is the only trigger firing the action.
However, this is "too late" as user profiles require this field value as available immediately after having logged in (preferably after 1st login).
But no trigger fires the action like onAfterLogin, onAfterLoginSuccess, onAfterFirstLogin (lastvisited condition), onAfterRegisterFormDisplay.

Don't have a clue why those triggers don't do the job.

Thank you in advance.

PS: in general I use [cb:config param="lang_tag" /] as substitution in SQL SELECTs. Works great, but in specific occurances this leads to false DB results.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48449
  • Thanks: 8280
  • Karma: 1443
7 years 6 months ago #293174 by krileon
Replied by krileon on topic Auto Action: only onAfterLogout working?
I don't understand the purpose of your condition. Additionally you have the language tag being passed through translations. So the condition should be removed and "Translate Value" should be set to "No". Then you need to use a trigger like onAfterLogin if you need the change immediately after login. Ensure Access is set to Everybody as well so it applies to all users.

PS: in general I use [cb:config param="lang_tag" /] as substitution in SQL SELECTs. Works great, but in specific occurances this leads to false DB results.

It would seam more appropriate to address your issue here and not need the auto action to begin with. What false DB results are you getting exactly? Note you should always treat all substitutions as strings. So in your query you should have '[cb:config param="lang_tag" /]' (with quotes).


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.

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
7 years 6 months ago #293190 by MMDoege
Replied by MMDoege on topic Auto Action: only onAfterLogout working?
Kyle, Thank you for your superquick response.

My website supports 6 languages which is handled by Joomla and CB perfectly.

Users work with many DB tables having field values in native language as well.
So a french user has a localized profile as well as DB fields in french.
As a sample, data is retrieved by a CB field type QUERY DROP DOWN MULTIPLE as follows:

SELECT industry_name FROM jos_industries
WHERE lang_tag='[cb:config param="lang_tag" /]'
AND cb_profile_selector='[cb_profile_selector]'
ORDER BY industry_name;

Provided user uses correct URL redirect (eg. www.domain.com/fr ) and doesn't switch browser lang settings everything works perfect.
However, when a user looks up a profile in another language, this concept fails.
Example: Italian user looks up a profile of a french user, both have stored data in their native language.
It's like magic:
CB translates the french profile into an italian profile as it uses the current setting of the viewers "lang_tag" which is it-IT not fr-FR.
But retrieval of french DB content fails as the above SELECT cannot find italian values in a french DB table.
This is an app design issue not an CB or Joomla issue.
However this issue is resolved when introducing a CB field that holds the value of "lang_tag" permanently from at time of registration or first login.
The italian user sees an italian profile of a french user where DB value are in french now.

Clicking on Joomla language switcher one can see the profile in french completely.

Therefore SELECT above is to be modified to:

SELECT industry_name FROM jos_industries
WHERE lang_tag='[cb_language_tag]'
AND cb_profile_selector='[cb_profile_selector]'
ORDER BY industry_name;

Drawback of this statement is that when TRIGGER=onAfterLogout user will have no localized DB data as cb_language_tag="" because not set.

My problem is that I don't know what combination of trigger, condition, a.s.o. to use of this mighty Auto Auction plug-in to choose.

The condition 1 EQUAL 1 is just a workaround for testing: execute action all time.
Correct condition is [cb: if cb_language_tag=""]1[/cb:if] EQUAL TO 1 YES.

Thank you for your service.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48449
  • Thanks: 8280
  • Karma: 1443
7 years 6 months ago #293197 by krileon
Replied by krileon on topic Auto Action: only onAfterLogout working?
Ok, so the main think you're actually needing is a substitute for the users language? The configuration substitution is always of the currently displayed language so you're correct in that it won't fit your needs and unsure if it'll really be able to handle your scenario even if stored, but you can try using the below.

Global
Triggers: onAfterUserRegistration and onAfterLogin
Type: Field
User: Automatic
Access: Everybody
Conditions
1: [cb_language_tag] Is Empty
Action
Field: cb_language_tag
Operator: Set
Value: [cb:config param="lang_tag" /]
Translate Value: No

There's a below feature ticket regarding improving this below so that the language substitution will substitute in the users language instead of site language if possible.

forge.joomlapolis.com/issues/6408


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.
The following user(s) said Thank You: MMDoege

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

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
7 years 6 months ago #293227 by MMDoege
Replied by MMDoege on topic Auto Action: only onAfterLogout working?
Thank you Kyle for your reply and considerations.

Well, Triggers: "onAfterUserRegistration and onAfterLogin" turned out not to be working the way assumed (no value set in DB table).
Even "1: [cb_language_tag] Is Empty" did not execute correctly. I had to stick to "[cb:if cb_language_tag=""]1[cb:if] EQUAL TO 1 " which was a surprise.

I'd to decide on a workaround with onAfterLogout which performs and re-wrote the SELECT to:

SELECT industry_name FROM jos_industries
WHERE
(lang_tag='[cb:config param="lang_tag" /]' OR lang_tag='[cb_language_tag]')
AND cb_profile_selector='[cb_profile_selector]'
ORDER BY industry_name;

Actually this is certainly not the most elegant way of programming but it solves the issue.
But it does the job (except when user2 user1 is viewing at in foreign language is just about executing very first session).

Thank you for your quick assistance.

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

Moderators: beatnantkrileon
Powered by Kunena Forum