Skip Navigation

[Resolved] Creating a field which is the calculate HASH of another field

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1150450

Hello,
I need to create a custom field where the content have to be the HASH key calculated from the file of another custom field (a file type).

It's really simple, in theory, but I can't find any tool which allow me to do this. Do you have any idea how I can resolve it ? A line of code ? The HASH would be SHA512

Thanks

#1150456

Hello,

There isn't such a built-in feature within Toolset plugins, it needs custom PHP codes, I suggest you try with wordpress action hook "save_post" to store the "HASH key calculated" value into the custom field.

For example:
1) When user create/edit a post, use action hook "save_post" to trigger a custom PHP function:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post

2) in this custom PHP function, you can get the "another custom field" field value:
https://developer.wordpress.org/reference/functions/get_post_meta/
Then setup custom PHP codes to get the HASH key calculated value, and save it into the custom field:
https://developer.wordpress.org/reference/functions/update_post_meta/

If your are using Toolset form to create/edit the post, you can try the action hook cred_save_data:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

For your reference.