Tell us what you are trying to do?
I am trying to copy a value from another custom field (postal code imported by another plugin) to the toolset maps adress field but i am no sure how to do that. Do i need to write a custom function for that or is there another way?
What is the link to your site? Unfortunately not it is still on development on localhost.
Steps i am trying to automate:
1: the postalcode is imported as a wordpress custom field as a textvalue by a third party plugin
2: i need to pass the postal code value to a toolset Radial search field called adress and the save/update the post
Its possible to copy this manual but i think there must be a way to automate this?
Hope anyone has an idea?
Hi you could automate this in a few different ways, but none of them are really supported here in the forums.
1. Create an export file that includes the zip code WordPress field. Manually modify the export file to include the same value in the Toolset custom field. Re-import the data into WordPress.
2. Create a custom SQL script that modifies the database directly. Types fields are stored with a "wpcf-" prefix in the postmeta table.
3. Write a PHP script using the save_post hook, to automatically copy the field value from one spot to another whenever the post is saved.
Also note that a zip-code only address isn't going to be very accurate for distance search. Google Maps puts the pin somewhere in the middle of the zip code area, but that could be several miles from the actual edge of the zip code. It's better to select a mappable address.
Hi Christian,
Thanks a lot for your answer and options. The radial search just needs to be a rough estimation so that will be fine.
Can you point me in the right direction or have an example for the php script option or is that beyond the scope of this support? I totally understand that ofcourse.
Anyway I am going for the php solution so I might be able to figure it out..
Thanks
There's an example in the WordPress documentation for updating a custom field in a custom post type "book" here:
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Here's another example showing how to get the value of a custom field using get_post_meta:
https://developer.wordpress.org/reference/functions/get_post_meta/
Types custom fields use the prefix 'wpcf-' in the database, so if your slug in wp-admin is "address" then the Types field in the database is "wpcf-address".
Thanks Christian, for the directions and your help!