{"id":1571,"date":"2016-12-08T15:13:36","date_gmt":"2016-12-08T20:13:36","guid":{"rendered":"http:\/\/cfdbplugin.com\/?page_id=1571"},"modified":"2016-12-08T15:18:56","modified_gmt":"2016-12-08T20:18:56","slug":"add-spaces-to-cf7-field-names","status":"publish","type":"page","link":"https:\/\/cfdbplugin.com\/?page_id=1571","title":{"rendered":"Add spaces to CF7 field names"},"content":{"rendered":"<p>Contact Form 7 does not permit spaces in field names. But we can add a WordPress filter function to add them. By convention, use an underscore &#8220;_&#8221; in field names where you want a space. For example &#8220;Team_Name&#8221;. Then add this filter to repace &#8220;_&#8221; with with a space so that this field is saved in CFDB as &#8220;Team Name&#8221;. <\/p>\n<p>Add the following code in your theme&#8217;s functions.php or via\u00a0<a href=\"http:\/\/wordpress.org\/extend\/plugins\/add-actions-and-filters\/\" target=\"_blank\">Add Shortcodes Actions and Filters plugin<\/a>.<\/p>\n<pre lang=\"php\" line=\"1\" escaped=\"true\">function filter_add_spaces_to_field_names($formData) {\r\n    foreach ($formData-&gt;posted_data as $key =&gt; $value) {\r\n        $key2 = str_replace('_', ' ', $key);\r\n        if ($key != $key2) {\r\n            unset($formData-&gt;posted_data[$key]);\r\n            $formData-&gt;posted_data[$key2] = $value;\r\n        }\r\n    }\r\n    return $formData;\r\n}\r\nadd_filter('cfdb_form_data', 'filter_add_spaces_to_field_names');<\/pre>\n<p>&nbsp;<br \/>\nSee also: <a href=\"\/?page_id=747\">Manipulating Data Before it is Saved<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contact Form 7 does not permit spaces in field names. But we can add a WordPress filter function to add them. By convention, use an underscore &#8220;_&#8221; in field names where you want a space. For example &#8220;Team_Name&#8221;. Then add this filter to repace &#8220;_&#8221; with with a space so that this field is saved [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1250,"menu_order":5,"comment_status":"closed","ping_status":"closed","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-1571","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/P1mptf-pl","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/1571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1571"}],"version-history":[{"count":4,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/1571\/revisions"}],"predecessor-version":[{"id":1575,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/1571\/revisions\/1575"}],"up":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/1250"}],"wp:attachment":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}