Hello.
I found this thread searching for a similar problem (capture IP, User-Agent). The proposed solutions above did not work for me too. I use this plugin https://cfdbplugin.com/ to save form data in database. It already captures IP address, so here’s my solution to add User-Agent:
1) Create a custom short-code in theme functions.php
function please_get_useragent_func( $atts ) {
return esc_html( substr( $_SERVER[‘HTTP_USER_AGENT’], 0, 254 ) );
}
add_shortcode( ‘please_get_useragent’, ‘please_get_useragent_func’ );
2) In your Contact Form add this line:
[dynamichidden useragent “please_get_useragent”]
3) Go to yourwebsite.com/wp-admin/admin.php?page=CF7DBPluginSubmissions to see submitted data.