How to page a function to a page template
-
Hi all…
I am developing a site on my local machine, yet there is something that I haven’t been able to figure out through searching through the support forums here and other PHP sites online.
I have a function, an ip-to-location function (to identify the region from which a visitor is coming from) that I can’t seem to get to work within the page of my page template. I have been able to get this function to print the ip and location information to the header of the page, but in the end that is not what I really want it to do. I would like for this information to populate a hidden form and then pass that information to my MySQL database…in order for other visible parts of the form (name, email, etc.) to be positively matched with that particular visitor’s ip and location.
The code that I have in the header file is:
function ip2location_get_vars() { static $ip2location_vars = NULL; if ( empty( $ip2location_vars ) ) { $ip2location_vars = array( 'header_var' => 'An header value' ); if ( is_tax() || is_category() || is_tag() ) { $ip2location_vars['taxonomy_var'] = 'A taxonomy value'; } } return $ip2location_vars; }
Any ideas and pointing in the right direction on how to do this with WP would be greatly appreciated!
- The topic ‘How to page a function to a page template’ is closed to new replies.