Title: Code suggestion &#8211; make name optional in api call
Last modified: May 3, 2021

---

# Code suggestion – make name optional in api call

 *  [Ken](https://wordpress.org/support/users/orangewebapps/)
 * (@orangewebapps)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/code-suggestion-make-name-optional-in-api-call/)
 * Getresponse returns an error if name is in the API call but empty; however it
   does not return error if name is not submitted at all. Often times a subscription
   form does not ask user for name. So I would suggest to change the code below 
   so not send “name” field if it is empty.
 * File: /lib/functions.php
    Line: 292-300
 *     ```
       if(strlen($name)){
       $body = '{
                          "name": "'.$name.'",
                          "email": "'.$email.'",
                          "dayOfCycle": "10",
                          "campaign": {
                              "campaignId":  "'.$list.'"
                           },
                           "customFieldValues":' . $cadarray . ' ' .
                       '}';
   
       }else{
              $body = '{
                          "email": "'.$email.'",
                          "dayOfCycle": "10",
                          "campaign": {
                              "campaignId":  "'.$list.'"
                           },
                           "customFieldValues":' . $cadarray . ' ' .
                       '}';
       }
       ```
   
    -  This topic was modified 5 years, 1 month ago by [Ken](https://wordpress.org/support/users/orangewebapps/).

The topic ‘Code suggestion – make name optional in api call’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cf7-getresponse_96dbf6.svg)
 * [Integrate Contact Form 7 and GetResponse](https://wordpress.org/plugins/cf7-getresponse/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-getresponse/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-getresponse/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-getresponse/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-getresponse/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-getresponse/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Ken](https://wordpress.org/support/users/orangewebapps/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/code-suggestion-make-name-optional-in-api-call/)
 * Status: not a support question