{"id":4196,"date":"2020-03-29T10:15:40","date_gmt":"2020-03-29T14:15:40","guid":{"rendered":"https:\/\/themespress.ca\/?p=4196"},"modified":"2021-11-17T06:55:58","modified_gmt":"2021-11-17T11:55:58","slug":"creating-a-custom-entry-id-for-formidable-form","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/creating-a-custom-entry-id-for-formidable-form\/","title":{"rendered":"Creating a Custom Entry ID For Formidable Form"},"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 create a custom ID or number for a <strong>Formidable Form<\/strong> and then update it with a custom field.<\/p>\n<p>The purpose of this function will be to generate an ID number for your ticket such as PO number, business number, reference number, etc&#8230;<\/p>\n<p>First of all, we will need to create a shortcode and include within it a PHP generator: the <a href=\"https:\/\/www.php.net\/manual\/fr\/function.mt-rand.php\" target=\"_blank\" rel=\"noopener noreferrer\">mt_rand()<\/a>. This generates a random value via the Mersenne Twister. <\/p>\n<p>Donc nous allons dans notre functions.php de notre WordPress et nous allons construire notre shortcode qui sera [idrand]. Dans cette fonction shortcode on lui demande de g\u00e9n\u00e9rer un nombre. On peut v\u00e9rifier sur le site, mais vous pouvez personnaliser ou argumenter votre<a href=\"https:\/\/www.php.net\/manual\/en\/function.mt-rand.php\" target=\"_blank\" rel=\"noopener noreferrer\"> mt_rand()<\/a>.<\/p>\n<p>Ex: Generate a number between 5 and 2000, you&#8217;d do this: <strong>mt_rand(5, 2000);<\/strong>.<br \/>\n In this case, we could simply ask the generator to generate a number without arguments so it could generate 87459612 for example.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<div id=\"ts-enlighterjs-container-1858040\" 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-1858040\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/\/ Add Shortcode\nfunction mafunction_number_entreprise_shortcode() {\n   return mt_rand() . &quot;\\n&quot;;\n}\nadd_shortcode( &#039;idrand&#039;, &#039;mafunction_number_entreprise_shortcode&#039; );<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Once you&#8217;ve inserted the shortcode, we will add a hidden field in the form where you will add the shortcode as its default value. <\/p>\n\n\t\t<\/div>\n\t<\/div>\n\n\t<div  class=\"wpb_single_image wpb_content_element vc_align_left wpb_content_element\">\n\t\t\n\t\t<figure class=\"wpb_wrapper vc_figure\">\n\t\t\t<div class=\"vc_single_image-wrapper   vc_box_border_grey\"><img decoding=\"async\" width=\"1872\" height=\"512\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1.jpg\" class=\"vc_single_image-img attachment-full\" alt=\"\" title=\"iprand\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1.jpg 1872w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-600x164.jpg 600w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-300x82.jpg 300w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-1024x280.jpg 1024w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-768x210.jpg 768w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-1536x420.jpg 1536w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-1-1320x361.jpg 1320w\" sizes=\"(max-width: 1872px) 100vw, 1872px\" \/><\/div>\n\t\t<\/figure>\n\t<\/div>\n\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Afterwards, we need to test the shortcode with the form to make sure it generates a number and that it&#8217;s not visible to users when they fill out the form. <\/p>\n\n\t\t<\/div>\n\t<\/div>\n\n\t<div  class=\"wpb_single_image wpb_content_element vc_align_left wpb_content_element\">\n\t\t\n\t\t<figure class=\"wpb_wrapper vc_figure\">\n\t\t\t<div class=\"vc_single_image-wrapper   vc_box_border_grey\"><img decoding=\"async\" width=\"1320\" height=\"58\" src=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2.jpg\" class=\"vc_single_image-img attachment-full\" alt=\"\" title=\"iprand-2\" srcset=\"https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2.jpg 1320w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2-600x26.jpg 600w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2-300x13.jpg 300w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2-1024x45.jpg 1024w, https:\/\/themespress.ca\/wp-content\/uploads\/2020\/03\/iprand-2-768x34.jpg 768w\" sizes=\"(max-width: 1320px) 100vw, 1320px\" \/><\/div>\n\t\t<\/figure>\n\t<\/div>\n\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Vous pouvez bien sur avec votre formulaire Formidable form, g\u00e9n\u00e9rer une action qui va permettre d&#8217;ajouter toutes les valeurs de votre formulaire dans un post type et ses champs personnalis\u00e9s.<br \/>\n(Tutoriel prochain)<\/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 create a custom ID or number for a Formidable Form and then update it with a custom field. The purpose of this function<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/creating-a-custom-entry-id-for-formidable-form\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4929,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[],"class_list":["post-4196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4196","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=4196"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4196\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4929"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}