kennym / cf7-to-api

LOOKING FOR MAINTAINER. Wordpress plugin to transmit contact form 7 entries to remote API using POST or GET
https://wordpress.org/plugins/cf7-to-api-basic-auth/
52 stars 30 forks source link

cf7 repeater fields #12

Closed Zetanova closed 4 years ago

Zetanova commented 4 years ago

https://github.com/kennym/cf7-to-api/blob/b9c4b71f753c1d982fb9485ae8789c0702177270/includes/class-cf7-api-admin.php#L358-L369

This code is assuming that all valid form fields are known at design time. the popular cf7 repeater plugin adds fields with an surfix of -1

quick fix/workaround

preg_match_all("/\[(\w+(-\d+)?)\]/", $properties['json_template'], $matches, PREG_PATTERN_ORDER); 
$properties['wpcf7_api_data_map'] = array_merge(array_fill_keys($matches[1], ''), $properties['wpcf7_api_data_map']);
kennym commented 4 years ago

@Zetanova if you can open a PR, I will make sure we'll get that merged! :-)

Zetanova commented 4 years ago

https://github.com/kennym/cf7-to-api/pull/13