Skip to Content Skip to Menu

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

AutoActions - Profile update - change value of submitted field

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago #237526 by OldLodgeSkins
Hi,

I'm trying to MD5 encode the value of a field when the user updates his profile. I thought it would be as simple as using a PHP(eval) action like this:
Code:
$_POST['myfield'] = md5($_POST['myfield']);

but I guess I was wrong.
Trigger: onAfterUserUpdate (is that correct?)
No conditions yet (although once this works I'll add one making sure the value has actually changed as I don't want to encode it over and over again).

I'm sure my mistake will be obvious to you...

Thanks.

Seb.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #237558 by krileon
The after update trigger is fired after the profile has been completely saved. You'll need to use the before update trigger with your same code, which may work.


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.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago - 10 years 11 months ago #237609 by OldLodgeSkins
This is strange...
I changed the trigger to OnBeforeUserUpdate, and enabled debug & maximum error reporting.
I did see in the debug info that the POST variable had been changed to an MD5 hash. So my PHP code was executed.
But then when I go check out my profile... It's the normal text that appears, not the hash, which would mean the hash wasn't saved in the database... Weird.
Last edit: 10 years 11 months ago by OldLodgeSkins.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #237637 by krileon
The field value was processed before your change to post. So your change to post didn't do anything in regards to storing. I suppose you can use prepareFieldDataSave, but it fires for every field being saved so be careful with its usage.


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.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago - 10 years 11 months ago #237641 by OldLodgeSkins
I guess I could limit its usage using a condition...
Can I set the condition to be true only if the submitted value is different from the already stored value? In which case the auto action wouldn't be triggered if the user doesn't change that password... It would be [cb_myfield] different from [var1_cb_myfield] is that correct?

Or maybe I could change directly the value that's being stored? I.e. instead of changing the POST value... I just let the system store the password in clear... Then encode it immediately. It might be better. I guess I would use directly [cb_myfield] to affect the stored one, right?
Last edit: 10 years 11 months ago by OldLodgeSkins.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #237648 by krileon

Can I set the condition to be true only if the submitted value is different from the already stored value? In which case the auto action wouldn't be triggered if the user doesn't change that password... It would be [cb_myfield] different from [var1_cb_myfield] is that correct?

Yes, you can try limiting it only if it was changed using something like the below.

[var1_cb_myfield] Not Equal To [post_cb_myfield]

Or maybe I could change directly the value that's being stored? I.e. instead of changing the POST value... I just let the system store the password in clear... Then encode it immediately. It might be better. I guess I would use directly [cb_myfield] to affect the stored one, right?

You can try using CB Query Field to display the field by querying for it directly in database then use SQL functions to alter it. I just don't quite understand why you want to encode it then display the encoded version of the field as that basically completely defeats the purpose of encoding it.


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