{"id":367,"date":"2011-04-01T13:48:11","date_gmt":"2011-04-01T17:48:11","guid":{"rendered":"http:\/\/cfdbplugin.com\/?page_id=367"},"modified":"2014-10-18T19:14:53","modified_gmt":"2014-10-18T23:14:53","slug":"accessing-form-data-via-php","status":"publish","type":"page","link":"https:\/\/cfdbplugin.com\/?page_id=367","title":{"rendered":"Accessing Form Data via PHP"},"content":{"rendered":"<p>If you want to programatically access a form&#8217;s data, follow this example code.<\/p>\n<pre lang=\"php\" line=\"1\">\/\/ Email all the Mike's\r\nrequire_once(ABSPATH . 'wp-content\/plugins\/contact-form-7-to-database-extension\/CFDBFormIterator.php');\r\n$exp = new CFDBFormIterator();\r\n$exp->export('my-form', array('show' => 'name,email', 'search' => 'Mike'));\r\nwhile ($row = $exp->nextRow()) {\r\n    wp_mail($row['email'], 'Hello ' . $row['name'], 'How are you doing?');\r\n}<\/pre>\n<p><strong>NOTES:<\/strong><\/p>\n<ol>\n<li>The second argument to &#8220;export&#8221; (the array) is optional. But use it to set options just as you would for shortcodes. The example above shows how to use the &#8216;search&#8217; shortcode option to limit entries (rows) to only those that have &#8220;mike&#8221; in them.<\/li>\n<li>Be sure to iterate over all of the data event if you do not use it (i.e. don&#8217;t &#8216;break&#8217; out of the while loop.). This is related to the fact that <a href=\"http:\/\/php.net\/manual\/en\/function.mysql-unbuffered-query.php\">mysql_unbuffered_query<\/a> call is being used behind the scenes.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>If you want to programatically access a form&#8217;s data, follow this example code. \/\/ Email all the Mike&#8217;s require_once(ABSPATH . &#8216;wp-content\/plugins\/contact-form-7-to-database-extension\/CFDBFormIterator.php&#8217;); $exp = new CFDBFormIterator(); $exp->export(&#8216;my-form&#8217;, array(&#8216;show&#8217; => &#8216;name,email&#8217;, &#8216;search&#8217; => &#8216;Mike&#8217;)); while ($row = $exp->nextRow()) { wp_mail($row[&#8217;email&#8217;], &#8216;Hello &#8216; . $row[&#8216;name&#8217;], &#8216;How are you doing?&#8217;); } NOTES: The second argument to &#8220;export&#8221; (the array) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":102,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"page-without-sidebar.php","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-367","page","type-page","status-publish","hentry"],"jetpack_shortlink":"https:\/\/wp.me\/P1mptf-5V","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/367","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=367"}],"version-history":[{"count":12,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/367\/revisions"}],"predecessor-version":[{"id":1233,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/367\/revisions\/1233"}],"up":[{"embeddable":true,"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=\/wp\/v2\/pages\/102"}],"wp:attachment":[{"href":"https:\/\/cfdbplugin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}