'User IP', // This will be the label of the field button in the back-end editor. 'display_function' => 'collect_user_ip_display', // This function will be called when the form is rendered on the front-end. 'sidebar' => 'template_fields', // This is the sidebar on the Field Settings tab that this field will show up in. 'display_label' => false, // Since we're adding a hidden form, we don't want to show the label on the front-end. 'display_wrap' => false, // Again, this is a hidden field, so we don't need the div wrapper that's normally output to the front-end. ); if( function_exists( 'ninja_forms_register_field' ) ) { ninja_forms_register_field('user_ip', $args); } } add_action( 'init', 'register_ip_field' ); /* * This function only has to output the specific field element. The wrap is output automatically. * * $field_id is the id of the field currently being displayed. * $data is an array the possibly modified field data for the current field. * */ function collect_user_ip_display( $field_id, $data ){ $ip = $_SERVER["REMOTE_ADDR"]; // Get our user's IP address. // The "name" attribute below is very important. It has to be ninja_forms_field_$field_id ?>