Skip to content

API: Shortcodes for Contact Form 7

Benjamin Pick edited this page May 19, 2020 · 11 revisions

These shortcodes you can use in forms created with WP ContactForm7:

Create a select input with all countries

(since 2.6.0)

Examples:

[geoip_detect2_countries mycountry id:id class:class lang:fr]
A list of all country names in French (with CSS id "#id" and class ".class"), the visitor's country is preselected.

[geoip_detect2_countries mycountry include_blank]
Country names are in the current site language. User can also choose '---' for no country at all.

[geoip_detect2_countries mycountry flag tel]
(since 3.0.5)
Country names have a UTF-8 flag in front of the country name, and the (+1) internation phone code after it

[geoip_detect2_countries mycountry "US"]
"United States" is preselected, there is no visitor IP detection going on here

[geoip_detect2_countries mycountry default:US]
Visitor's country is preselected, but in case the country is unknown, use "United States"

@param string $id CSS Id of element
@param string $class CSS Class of element
@param string $lang Language(s) (optional. If not set, current site language is used.)
@param string $default 		Default Value that will be used if country cannot be detected (optional)
@param string $include_blank If this value exists, a empty value will be prepended ('---', i.e. no country) (optional)

Create a text input that is prefilled with a geodetected property

(since 2.10.0)

Property can be: continent, country, city, postal.code or any other property understood by geoip_detect2_get_info_from_ip

Examples:

[geoip_detect2_text_input property:city lang:fr id:id class:class]
A text input that has the detetected city as default (with CSS id "#id" and class ".class")

[geoip_detect2_text_input property:city lang:fr id:id class:class default:Paris]
As above, but in case the city is unknown, use "Paris"

Insert the geoinfos of the user into the email text

(since 2.6.0)

Just use [geoip_detect2_user_info] in the email body. The result will me like this:

IP of the user: 88.64.140.3
Country: Germany
State or region: Hesse
City: Eschborn

Data from: GeoLite2 City database

If you want to customize the labels or formatting ... use this text in the email body as starting point (since 2.9.1):

IP of the user: [geoip_detect2_get_client_ip]
Country: [geoip_detect2_property_country]
State or region: [geoip_detect2_property_region]
City: [geoip_detect2_property_city]

Data from: [geoip_detect2_get_current_source_description]

Result: same as above.

Clone this wiki locally