I have a public node creation form that unauthenticated users will submit. I want to save the visitor's geographical location with the node that they create. I imagine capturing their lat/lon and inserting that into a hidden field in the form.

For reading the lat/lon, I have Smart IP installed. I've tried to use Smart IP's tokens to insert the values into a field, but I get an error: Undefined index: longitude in smart_ip_tokens()

At this point, I will try any way of reading and capturing the user's lat/lon and of associating it with the node that the visitor creates.

Any suggestions, please?

UPDATE: the Smart IP tokens are successfully inserting the lat and lng as default values into text fields that I've "hidden" from public view by disabling them in Display Suite.

This notice continues to show: Undefined index: latitude in smart_ip_tokens() (line 309 of ../modules/contrib/smart_ip/smart_ip.module). Further, the error displays in FF v.27.0.1, not in Chrome v.33, not in IE11 and it is present on both the node-create form and the node display.

  • You can try Computed Field module. It will help you to capture lat/lon even using php code or token.
    – Rupesh
    Mar 13 '14 at 2:59
  • @Gisle Hannemyr, I have field_default_token installed and the token module. I added a text field to my content type and copy/pasted the token [smart_ip:longitude] into the default of the field.
    – mastoll
    Mar 13 '14 at 12:31
  • @Rupesh - thanks for the Computed Field suggestion. Even though I am mostly successful with tokens and field defaults, the errors persist, and I'm hoping that by using the php get script that Smart IP provides on the project page I can get around the token-related errors.
    – mastoll
    Mar 13 '14 at 23:11

Your Answer

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

Browse other questions tagged or ask your own question.