{"id":4345,"date":"2022-07-13T09:47:58","date_gmt":"2022-07-13T08:47:58","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=4345"},"modified":"2026-02-22T08:59:51","modified_gmt":"2026-02-22T08:59:51","slug":"form-nonce","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/forms-wordpress\/form-nonce","title":{"rendered":"Form nonce"},"content":{"rendered":"\n<p>Using a nonce with your forms validates that the contents of the form came from the location on the current site and not somewhere else.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using with a form<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Create the nonce HTML<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>$OurNonceField = wp_nonce_field( 'MySiteSomeUniqueNonceName', 'my_site_request_nonce', true, false );   \/\/Used to validate that the contents of the form request came from the current site and not somewhere else<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Include it in the form contents<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;form method=\"POST\"&gt;\n\n  $OurNonceField\n\n&lt;\/form&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Verifying the nonce when receiving the form submission<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/-------------------------------------\n  \/\/----- A FORM HAS BEEN SUBMITTED -----\n  \/\/-------------------------------------\n\n  \/\/CHECK THE FORM NONCE FIELD IS VALID\n  if (\n    (!isset( $_POST&#91;'my_site_request_nonce'])) ||\n    (wp_verify_nonce($_POST&#91;'my_site_request_nonce'], 'MySiteSomeUniqueNonceName') !== 1)       \/\/1=nonce created within last 12 hours\n  )\n  {\n    wp_redirect( home_url( '\/' ) );\n    die;\n  }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using a nonce with your forms validates that the contents of the form came from the location on the current site and not somewhere else. Using with a form Create the nonce HTML Include it in the form contents Verifying the nonce when receiving the form submission<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[346],"tags":[],"class_list":["post-4345","post","type-post","status-publish","format-standard","hentry","category-forms-wordpress"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=4345"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4345\/revisions"}],"predecessor-version":[{"id":5292,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/4345\/revisions\/5292"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=4345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=4345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=4345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}