{"id":4000,"date":"2020-07-27T16:43:03","date_gmt":"2020-07-27T20:43:03","guid":{"rendered":"https:\/\/themespress.ca\/?p=4000"},"modified":"2021-11-16T21:23:12","modified_gmt":"2021-11-17T02:23:12","slug":"formidable-form-display-users-ip","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/formidable-form-display-users-ip\/","title":{"rendered":"Formidable Form: Display User&#8217;s IP"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>This tutorial will show you how to fetch your user&#8217;s ID and IP address and display it under the Admin column in the WordPress dashboard.<\/p>\n<p>First off, how to fetch the user&#8217;s IP address with the form. In your form, <a href=\"https:\/\/shareasale.com\/r.cfm?b=841990&amp;u=1476870&amp;m=64739&amp;urllink=&amp;afftrack=\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Formidable Form<\/strong><\/a>, we will create a hidden form and in its advanced parameters, we will look up a default value which will be the IP address.<br \/>\n<div id='gallery-1' class='gallery galleryid-4000 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon portrait'>\n\t\t\t\t<a href='https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/Get-IP.jpg'><img decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/Get-IP-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/Get-IP-150x150.jpg 150w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/Get-IP-100x100.jpg 100w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/IP.jpg'><img decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/IP-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/IP-150x150.jpg 150w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/07\/IP-100x100.jpg 100w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n<p>Donc concr\u00e8tement, quand l&#8217;utilisateur va poster son formulaire, \u00e7a va avoir l&#8217;adresse IP en champ cach\u00e9. When a user will send the form, the hidden form will contain their IP. The next step will be to display it in a column in the WordPress user section.<\/p>\n<p>We will add two new filters <a href=\"http:\/\/hookr.io\/filters\/manage_users_columns\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>manage_users_columns<\/strong><\/a> and <a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/manage_users_custom_column\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>manage_users_custom_column<\/strong><\/a><\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-2870650\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-2870650\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"custom\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">function add_column( $column ) {\n    $column[&#039;userip&#039;] = &#039;IP utilisateur&#039;;\n    return $column;\n}\nadd_filter( &#039;manage_users_columns&#039;, &#039;add_column&#039; );\n\n\/*this will add column value in user list table*\/\nfunction add_column_value( $val, $column_name, $user_id ) {\n   switch ($column_name) {\n        case &#039;userip&#039; :\n\t\/\/ Remplacer 1094 par l&#039;ID du champ cach&eacute; de votre formulaire IP Adress\n        return FrmProEntriesController::get_field_value_shortcode(array(&#039;field_id&#039; =&amp;gt; 1094, &#039;entry&#039; =&amp;gt; $entry_id, &#039;user_id&#039; =&amp;gt; $user_id));\n        break;\n        default:\n    }\n    return $val; \n}\nadd_filter( &#039;manage_users_custom_column&#039;, &#039;add_column_value&#039;, 10, 3 );<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Pour obtenir notre valeur IP de l&#8217;utilisateur, nous allons utiliser <a href=\"https:\/\/formidableforms.com\/knowledgebase\/get-a-value-from-an-entry\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>FrmProEntriesController::get_field_value_shortcode<\/strong><\/a> that will allow you to display the Formidable form&#8217;s value of the field and inclure an argument is necessary.<\/p>\n<p>In our return Query, we have added the following arguments: <strong>field_id<\/strong>, <strong>entry<\/strong>, and <strong>user_id<\/strong>  matching the user&#8217;s ID in the results table. This means, for example, to fetch the value matching the ID 1094 of each value each user ID.<br \/>\n<strong><br \/>\nNB: Make sure to do a backup of your theme, files and database before proceeding with these tutorials.<\/strong><\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"This tutorial will show you how to fetch your user's ID and IP address and display it under the Admin column in the Wordpress dashboard. First off, how to fetch<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/formidable-form-display-users-ip\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4908,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[332,351,313],"class_list":["post-4000","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-body","tag-forms","tag-plugins"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4000","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=4000"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4000\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4908"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}