From 2fa094b018ec7c3cae4de9624cb3eadf844f549c Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Sun, 18 Oct 2020 13:00:16 +0200 Subject: [PATCH 1/5] improve variable naming --- includes/class-cf7-zwr-field-finder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-cf7-zwr-field-finder.php b/includes/class-cf7-zwr-field-finder.php index 87700ba..084aaa1 100644 --- a/includes/class-cf7-zwr-field-finder.php +++ b/includes/class-cf7-zwr-field-finder.php @@ -21,8 +21,8 @@ public function prefixed($namespace = 'cf7zwr-') { foreach($this->fields as $key => $value) { if(strpos($key, $namespace) === 0) { - $new_key = substr($key, $length); - $fields_with_prefix[$new_key] = $value; + $key_without_prefix = substr($key, $length); + $fields_with_prefix[$key_without_prefix] = $value; } } From 60260f6989e0891bde602f3c0e7b6bd28b407eda Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Sun, 18 Oct 2020 14:12:49 +0200 Subject: [PATCH 2/5] skips registration if webinar id doesnt exist --- includes/class-cf7-zwr-api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-cf7-zwr-api.php b/includes/class-cf7-zwr-api.php index 936042c..de4bebe 100644 --- a/includes/class-cf7-zwr-api.php +++ b/includes/class-cf7-zwr-api.php @@ -78,6 +78,10 @@ public function send_registration($contactform, &$abort, $submission) { $posted_data = $submission->get_posted_data(); $webinar_id = get_post_meta($contactform->id(), 'cf7zwr-webinar_id', true); + if (!$webinar_id) { + return $wpcf; + } + $field_parser = new CF7_ZWR_Field_Finder($posted_data); $fields = $field_parser->combine(['guessed', 'prefixed']); From b9293273a3a5db5ec6e78690e8d439a26f86673d Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Sun, 18 Oct 2020 14:13:48 +0200 Subject: [PATCH 3/5] sends registration if optional field exists and is checked #3 --- includes/class-cf7-zwr-api.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/class-cf7-zwr-api.php b/includes/class-cf7-zwr-api.php index de4bebe..62466eb 100644 --- a/includes/class-cf7-zwr-api.php +++ b/includes/class-cf7-zwr-api.php @@ -85,7 +85,10 @@ public function send_registration($contactform, &$abort, $submission) { $field_parser = new CF7_ZWR_Field_Finder($posted_data); $fields = $field_parser->combine(['guessed', 'prefixed']); - if ($webinar_id) { + if (!array_key_exists('cf7zwr-confirm', $posted_data)) { + $this->build($this->api_url . '/webinars/' . $webinar_id . '/registrants', array('body' => wp_json_encode($fields)), 'POST'); + $this->run($this->token); + } elseif ($posted_data['cf7zwr-confirm'][0]) { $this->build($this->api_url . '/webinars/' . $webinar_id . '/registrants', array('body' => wp_json_encode($fields)), 'POST'); $this->run($this->token); } From 0c238df081cc1736a191d9c847678c5f895740fc Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Sun, 18 Oct 2020 14:51:28 +0200 Subject: [PATCH 4/5] adjusts readme --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 53b05c4..981ab6d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,11 @@ Allow registrations for your Zoom Webinar through Wordpress Contact Form 7 2. The plugin looks for field names prefixed with `cf7zwr-`. The rest of the field name should be according to the [Zoom API reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinarregistrantcreate). For example if you want to save the first name of a registrant the field should be named `cf7zwr-first_name` 3. The webinar ID can be saved within the form settings inside the `Zoom` panel +## Additional Settings + +To register users optionally add a checkbox element named `cf7zwr-confirm` to your form e.g. +`[checkbox cf7zwr-confirm "Register for this webinar"]` + ## License This plugin is licensed under the GPL v3. See `license.txt` for more information. @@ -32,6 +37,10 @@ If you find any Bugs please feel free to [open an issue here](https://github.com ## Changelog +#### [1.0.6] - 2020-10-18 +- Skips Zoom API Call if there is no webinar id present +- Checks for a field `cf7zwr-confirm` to register users optionally + #### [1.0.5] - 2020-08-07 - Fixes a bug that caused guessed fields to overwrite prefixed fields From 2865a88d0a02e1847fbd95e1c683071b4969ef4e Mon Sep 17 00:00:00 2001 From: Usame Algan Date: Sun, 18 Oct 2020 14:52:42 +0200 Subject: [PATCH 5/5] update version --- cf7-zoom-webinar-registration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cf7-zoom-webinar-registration.php b/cf7-zoom-webinar-registration.php index befeffe..335492b 100644 --- a/cf7-zoom-webinar-registration.php +++ b/cf7-zoom-webinar-registration.php @@ -3,7 +3,7 @@ Plugin Name: CF7 Zoom Webinar registration Plugin URI: https://github.com/usame-algan/cf7-zoom-webinar-registration Description: Allow registrations for your Zoom Webinar through Wordpress Contact Form 7 - Version: 1.0.5 + Version: 1.0.6 Author: Usame Algan Author URI: https://usamealgan.com Text Domain: cf7-zwr @@ -17,7 +17,7 @@ * Plugin constants */ if (!defined('CF7_ZWR_VERSION')) { - define('CF7_ZWR_VERSION', '1.0.5' ); + define('CF7_ZWR_VERSION', '1.0.6' ); } if (!defined('CF7_ZWR_PATH')) {