After a user submits a SafeCracker form, is there a way for me to take a value from the submitted form, run it through a process, then set other Channel field values?

I'm allowing users to enter their address. I need to convert that address to lat/lng values, which my Channel has fields for. I do not want my users to ever see this lat/lng value, so I never present it in the forms they see. The lat/lgn values are critical, though; I need them.

2 Answers 2


Yes, this is indeed possible - what you'd need to do however is to create a custom extensions which hooks into the Safecracker hooks - particularly 'safecracker_submit_entry_start'. More information about the hooks are available here

The hook will pass you the safecracker library object, which you should then be able to manipulate performing whatever data wrangling you need, update the object and then pass it back to Safecracker for onward processing.

Alternatively, you could just do it via jQuery/AJAX prior to the form being submitted? Google has a really good API which will convert postal codes to lat/lng values which you could then inject into your post array before submitting it.

[edit] If you want a helping hand creating an extension, I thoroughly recommend pkg.io - should give you a good head start.

  • I plan to use Google Maps API. I suppose doing JS and setting a couple of hidden fields would work, but my concern is if the user has JS turned off. (Hidden fields would work, right?) I'll take a look at Safecracker hooks. If it's too much trouble, I'll do the JS solution. Dec 21, 2012 at 11:31
  • OK, I'm new to EE. I'm not sure if that page gave me enough details. I guess I'll try to find out information about "custom extensions" first. Dec 21, 2012 at 11:34
  • Do I have to call $this->EE->extensions->call('safecracker_submit_entry_start', $this); manually? Dec 24, 2012 at 8:59

Take a look at my registration form on my site. It does exactly what you want, I even show a map so the user can verify their address. (You can't see them, but it's storing the lat/lng as well as the location on a map.)


You will see it's a simple form using my Safecracker Registration add-on. Same thing works with a regular safecracker form too. This is powered totally by my Google Maps for ExpressionEngine add-on.


Google Maps for EE provides all the tools to speed up exactly what you are trying to do. There is a plugin called addressValidation.js included, which would essentially get you up and running in a few minutes. No need to mess with the Google Maps API directly using Google Maps for EE. I am confident that is the best and easiest solution, although not free. The Google Maps for EE API has by far the most features of any mapping add-on.

Just let me know if you have any questions. Happy to help you get this setup should you choose to go this route.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.