Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Substitution old_email and new_email ?

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 2 months ago - 11 years 2 months ago #231594 by dotcom22
Substitution old_email and new_email ? was created by dotcom22
hello

I need to make a Post request (using trigger AfterUserUpdate) with Auto-Action for reach an API located on remote server. The goal is to update email address in both Joomla and remote server but I need to place in my request the old email and the new email otherwise the Api cannot work.

Actually the substitution email correspond always to current email (that mean the new address) and I wondering how to do for get the old email.

any clue ?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 2 months ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 2 months ago #231596 by krileon
Replied by krileon on topic Substitution old_email and new_email ?
var1 contains the new user object. var3 contains the old user object. So you can use the two below to pull straight from user object with the after user update trigger.

New Email: [var1_email]
Old Email: [var3_email]


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 2 months ago - 11 years 2 months ago #232015 by dotcom22
Replied by dotcom22 on topic Substitution old_email and new_email ?
hello

I just need a clarification because I get some issue and suddenly I have a doubt... My goal is to fire a Post request1 Before user update and to fire a post request2 After user update.

So when user update his profile, the trigger BeforeUserUpdate allow to fire my Post request1 BEFORE new or modified data are entered inside database...right ?

That mean for example if I set my Post Url like this:

BeforeUserUpdate
Code:
http://api.domain.com/rest/?method=modify_user&api_key=123456789&api_first_name=[firstname]

AfterUserUpdate
Code:
http://api.domain.com/rest/?method=modify_user&api_key=123456789&api_first_name=[firstname]

and if user change his first name from Mike to Steve, the real Url who will be sent is:

BeforeUserUpdate
Code:
http://api.domain.com/rest/?method=modify_user&api_key=123456789&api_first_name=Mike

AfterUserUpdate
Code:
http://api.domain.com/rest/?method=modify_user&api_key=123456789&api_first_name=Steve

Correct ??

please confirm..

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 2 months ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 2 months ago #232018 by krileon
Replied by krileon on topic Substitution old_email and new_email ?

So when user update his profile, the trigger BeforeUserUpdate allow to fire my Post request1 BEFORE new or modified data are entered inside database...right ?

The user object has been modified at this point, but it has not been stored in database yet. The before/after user update triggers share the same variables.

Correct ??

No, use var1 and var3 usage as shown in my above reply. So for example BeforeUserUpdate would be [var3_firstname] and AfterUserUpdate would be [var1_firstname].


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 2 months ago - 11 years 2 months ago #232091 by dotcom22
Replied by dotcom22 on topic Substitution old_email and new_email ?
Ok I see but now I'm facing a problem and I don't see how to solve it. Finally after some test, I realize I just need to use BeforeUserUpdate trigger. Then instead to use Auto-Action, I use now a custom CB plugin because I need to know the returned response of remote server before continue or interrupt CB update process (unfortunately Auto-Action do not allow this). My goal is to fire a remote API for sync user data between Joomla and this remote software. The post Url I use look like this:
Code:
http://api.remote-server.com/rest/?method=modify_user&api_key=123456789&email=[var3_email]&new_email=[var1_email]&first_name=[firstname]&last_name=[lastname]

This Url work fine and all data are well updated in both location BUT only if user modify/update his email. If for example user want only update his lastname, the remote Api make an error because the value related to [var3_email] seem to be not passed in Url.

In fact for what I understand, CB handle [var3_email] AND [var1_email] only when email are modified. If is not modified these value don't make sense and related tag are not replaced with related value (such current@email.com for tag [var3_email] and null for [var3_email]) . So I wondering how to handle the case...

I suppose the only way could be to use 2 Api Url instead only one that mean like this:

Email is not modified:
Code:
http://api.remote-server.com/rest/?method=modify_user&api_key=123456789&email=[email]&first_name=[firstname]&last_name=[lastname]

Email is modified:
Code:
http://api.remote-server.com/rest/?method=modify_user&api_key=123456789&email=[var1_email]&new_email=[var1_email]&first_name=[firstname]&last_name=[lastname]

Then is necessary to detect if email as been modified and according to this, fire the related Url...

This make sense ? Have you some other suggestion ?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 2 months ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 2 months ago #232106 by krileon
Replied by krileon on topic Substitution old_email and new_email ?

Then instead to use Auto-Action, I use now a custom CB plugin because I need to know the returned response of remote server before continue or interrupt CB update process

Just use a Code action with PHP method then set a plugin error to interrupt profile update. You can do your custom HTTP request in the PHP method. Example of how to trigger an error as follows.

Code:
global $_PLUGINS; $_PLUGINS->_setErrorMSG( 'My error message.' ); $_PLUGINS->raiseError( 1 );

(unfortunately Auto-Action do not allow this)

Correct, CB Auto Actions does its best not to interrupt normal processes on purpose as it could easily cause too many issues if configured wrong. I don't really suggest interrupting CB due to an HTTP request failing though.

This make sense ?

Not really. You're making a simple synchronize too complicated.

Have you some other suggestion ?

Yes, use the after profile update trigger and just fire an HTTP request as follows using a Request action. Disregard whether your 3rd party system fails or not as you don't want it negatively impacting your main site.

Code:
http://api.remote-server.com/rest/?method=modify_user&api_key=123456789&email=[email]&first_name=[firstname]&last_name=[lastname]

You should fire the above after every profile update so it always remains up to date. You should handle whether you need to do an actual update or not in your 3rd party solutions endpoint. So for example if I called the above then whenever the HTTP request is processed it should check if any of those have changed comparing against existing values and if they have then save and if not then just disregard the request.


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