Title: Default select radio button
Last modified: September 19, 2016

---

# Default select radio button

 *  [unaj41](https://wordpress.org/support/users/unaj41/)
 * (@unaj41)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/)
 * Hello,
 * I have a setup with three radio-buttons for three different download links email
   option.
    As default none of the radio-buttons are selected. The plugin doesn’t
   seem to check if any of them are selected (required) so if user forgets or omits
   to choose one of the options then the email contains all three links… How to 
   prevent this?
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8200564)
 * I have never actually tried using radio buttons, only checkboxes. Obviously, 
   with checkboxes it’s a multiple download, while radio buttons -should- require
   a single one to be selected.
 * With checkboxes, you can put checked=”yes” in the shortcode and that will default
   all the checkboxes to the checked state … that helps some, but the user can still
   deselect all of them and then hit submit, meaning it goes through without anything
   selected and EBD does not handle it well. I suspect that the end result is the
   same thing as your radio buttons with none of them selected. In my own copy of
   the plugin, I adjusted the source code to fix the issue I was seeing with nothing
   selected (for checkboxes). I’m guessing that the same fix might work for you.
   It requires you to modify a line of code in email-before-download.php. Once you
   do that, obviously you’ll need to remember to make the same modification again
   if you ever update the plugin (assuming some new version came out in the future..
   something that is pretty rare, fortunately).
 * Anyway, here is the code change. At around line 562 of email-before-download.
   php you should see this line:
 *     ```
       else if(!empty($d) || !empty($ebd_item->file) ){
       ```
   
 * Change it to be this:
 *     ```
       else if( (!empty($d) || !empty($ebd_item->file)) && strpos($ebd_item->download_id,',') === FALSE ){
       ```
   
 * (note that that scrolls off to the right so make sure you get the whole thing
   as it’s quite a bit longer than before)
 * Then test again and this time it should catch it if nothing is selected (hopefully)
   and give an error.
    -  This reply was modified 9 years, 10 months ago by [dtynan](https://wordpress.org/support/users/dtynan/).
 *  Thread Starter [unaj41](https://wordpress.org/support/users/unaj41/)
 * (@unaj41)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8200688)
 * Awesome! Thanks, that did it – user gets an error message if nothing’s selected.
   
   And no default selection is probably the best solution anyways: it forces user
   to make a choice hence preventing sending wrong file/link, if default selection
   is not validated by user… Thanks again!
 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8200776)
 * glad to hear it works. Make sure to test it for the positive too … as in, select
   a radio button and submit and make sure it still works. Now that I’m looking 
   at it again, I’m not 100% sure it will.
 *  Thread Starter [unaj41](https://wordpress.org/support/users/unaj41/)
 * (@unaj41)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8203474)
 * … it seems to be working… i can’t break it 😉
    The only bug that is minor to 
   me is that in the export csv file the “**item_title**” column has always all 
   three values when in fact only one is being sent… however “**selected_id**” column
   correctly identify the download id number…
    -  This reply was modified 9 years, 10 months ago by [unaj41](https://wordpress.org/support/users/unaj41/).
 *  [dtynan](https://wordpress.org/support/users/dtynan/)
 * (@dtynan)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8204732)
 * yeah mine does the same thing

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Default select radio button’ is closed to new replies.

 * ![](https://ps.w.org/email-before-download/assets/icon-256x256.jpg?rev=1813522)
 * [Email Before Download](https://wordpress.org/plugins/email-before-download/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/email-before-download/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/email-before-download/)
 * [Active Topics](https://wordpress.org/support/plugin/email-before-download/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/email-before-download/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/email-before-download/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [dtynan](https://wordpress.org/support/users/dtynan/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/default-select-radio-button/#post-8204732)
 * Status: not resolved