Skip Navigation

[Resolved] copy value from other custom field to toolset adress field

This support ticket is created 5 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Wim 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1234375

Wim

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.

#1234722

Wim

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?

#1234730

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.

#1234858

Wim

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

#1235132

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".

#1235263

Wim

Thanks Christian, for the directions and your help!