Created
October 2, 2015 14:45
-
-
Save darknailblue/41607eb739fd7e7ccf4f to your computer and use it in GitHub Desktop.
Adds user agent information to the entry admin screen for Gravity Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'gform_entry_info', 'djb_gform_entry_info', 10, 2 ); | |
| function djb_gform_entry_info( $form, $lead ) { | |
| // Show IP info link if address is IPv4 and not in private or reserved range | |
| if ( isset( $lead['ip'] ) && filter_var( $lead['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) { | |
| $ip_info_url = 'http://' . $lead['ip'] . '.ipaddress.com'; | |
| echo '<a href="' . esc_url( $ip_info_url ) . '" target="_blank">IP info</a>'; | |
| } | |
| if ( isset( $lead['ip'] ) && isset( $lead['user_agent'] ) ) { | |
| echo '<br><br>'; | |
| } | |
| if ( isset( $lead['user_agent'] ) ) { | |
| _e( 'User Agent', 'gravityforms' ); | |
| echo ': ' . esc_html( $lead['user_agent'] ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment