Title: [Plugin: WP-Polls] Need help with adding Input Text field
Last modified: August 20, 2016

---

# [Plugin: WP-Polls] Need help with adding Input Text field

 *  Resolved [krieg](https://wordpress.org/support/users/krieg/)
 * (@krieg)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/)
 * Great job with this plugin Lester Chan,
 * I need help with the following.
    Right now I am trying to create a poll using
   the poll templates with 2 input text fields, I need this for email harvesting
   from my users before voting, I will only need to asked them to fill Name and 
   E-mail. Using the poll template below and added into wp template option
 *     ```
       <p style="text-align: center;"><strong>%POLL_QUESTION%</strong></p><div id="polls-%POLL_ID%-ans" class="wp-polls-ans"><ul class="wp-polls-ul">
   
       <label for="name" id="name_label">Name</label>
             <input type="text" name="name" id="name" size="30" value="" class="text-input" />
        <label for="email" id="email_label">Return Email</label>
             <input type="text" name="email" id="email" size="30" value="" class="text-input" />
       ```
   
 * Sadly, tweaking the polls-js.js and jquery to read the #name and #email IDs are
   not working.
    I declared the variable and everything, tried using ajax to send
   the values to the php without success.
 *     ```
       var dataString = 'name='+ name;
       jQuery.ajax({
       type: 'POST', url: pollsL10n.ajax_url,
       data: dataString,
       cache:false,
       success: poll_process_success});
       ```
   
 * on WP-POLL.PHP
 *     ```
       $name = $_POST["name"];
       $email = $_POST["email"];
       ```
   
 * altered the database to include the name and email field, which works.
 *     ```
       $wpdb->query("INSERT INTO $wpdb->pollsip VALUES (0, $poll_id, $polla_aid, '$pollip_ip', '$pollip_host', '$pollip_timestamp', '$pollip_user', '$name', '$email', $pollip_userid)");
       ```
   
 * However it fails to retrieve the value of the input on the form, and on wp-polls.
   php it will not read the string. I really dont know what to do to make it work.
 * I areadly manage to add name and email columns in pollip database table.
    which
   loops on every vote but it will not populate the name and email table.
 * I am using a test wordpress install on my pc using xampp, and with only wp=polls
   available. the idea show look like this on the widget.
 * [http://i48.tinypic.com/2ugc9s7.jpg](http://i48.tinypic.com/2ugc9s7.jpg)
 * Thanks in Advance,
    Krieg
 * [http://wordpress.org/extend/plugins/wp-polls/](http://wordpress.org/extend/plugins/wp-polls/)

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

 *  Thread Starter [krieg](https://wordpress.org/support/users/krieg/)
 * (@krieg)
 * [13 years, 12 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2779998)
 * I solved it…
 *  [junobeach20](https://wordpress.org/support/users/junobeach20/)
 * (@junobeach20)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780036)
 * Hi Krieg. I am looking to do the exact same thing and haven’t gotten anywhere.
   Would you be interested in helping me out? My email address is [jakecarney@mac.com](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/jakecarney@mac.com?output_format=md)
 * Thanks!
    Jake
 *  [wglassbrook](https://wordpress.org/support/users/wglassbrook/)
 * (@wglassbrook)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780050)
 * I would also be interested in adding additional input fields into a poll. Perhaps
   a tutorial is in order?
 *  [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * (@digitalrub)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780055)
 * I’m looking to do the exact same thing. How did you finally solve it?
 *  [monweb](https://wordpress.org/support/users/monweb/)
 * (@monweb)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780087)
 * I’m looking to do the exact same thing too. :\
 *  [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * (@digitalrub)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780088)
 * ok, this is how i got it to work. Not saying this is the best way to do it, or
   even a good/secure way to do it – but it throws data in the table. I added my
   extra fields to polls_ip through phpmyadmin.
 * I added my fields to the form footer in the template interface:
 *     ```
       <div id="frm_field_8_container" class="frm_form_field form-field  frm_required_field frm_top_container">
           <label class="frm_primary_label">NAME    </label>
           <input type="text" id="pollip_name" name="pollip_name" value="" class="texty"></div>
   
       <div id="frm_field_9_container" class="frm_form_field form-field  frm_required_field frm_top_container">
           <label class="frm_primary_label">EMAIL  </label>
           <input type="text" id="pollip_email" name="pollip_email" value="" class="text required">
        </div>
   
       <div id="frm_field_10_container" class="frm_form_field form-field  frm_required_field frm_top_container">
           <label class="frm_primary_label">ZIP CODE</label>
           <input type="text" id="pollip_zipcode" name="pollip_zipcode" value="" class="text required">
       </div>
       <div id="frm_field_12_container" class="frm_form_field form-field  frm_required_field frm_top_container">
           <label class="frm_primary_label">CURRENT CARRIER    </label>
           <input type="text" id="pollip_carrier" name="pollip_carrier" value="" class="text required">
       </div>
       ```
   
 * Then I changed the polls-js.js to the polls-js.dev.js in wp-polls.php.
 * Then in polls-js.dev.js at line 19:
 *     ```
       var pollip_name = '';
       var pollip_email = '';
       var pollip_zipcode = '';
       var pollip_carrier = '';
       ```
   
 * Under this function `jQuery('#polls_form_' + poll_id + ' input:checkbox, #polls_form_'
   + poll_id + ' input:radio').each(function(i)` I added:
 *     ```
       jQuery('.texty').each(function(){
   
       				pollip_name = jQuery('#pollip_name').val();
       				pollip_email = jQuery('#pollip_email').val();
       				pollip_zipcode = jQuery('#pollip_zipcode').val();
       				pollip_gender = jQuery('#pollip_gender').val();
       				pollip_carrier = jQuery('#pollip_carrier').val();
   
       		});
       ```
   
 * Then in wp-polls.php line 1305:
 *     ```
       $pollip_name= $_POST["pollip_name"];
         $pollip_email= $_POST["pollip_email"];
         $pollip_zipcode= $_POST["pollip_zipcode"];
         $pollip_carrier= $_POST["pollip_carrier"];
       ```
   
 * Then updated this query to include my fields:
 * `INSERT INTO $wpdb->pollsip VALUES (0, $poll_id, $polla_aid, '$pollip_ip', '$
   pollip_host', '$pollip_timestamp', '$pollip_user', $pollip_userid, '$pollip_name','
   $pollip_email', '$pollip_zipcode', '$pollip_carrier')`
 *  [monweb](https://wordpress.org/support/users/monweb/)
 * (@monweb)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780090)
 * Thanks a lot digitalrub.
    I gonna try this in the afternoon.
 *  [monweb](https://wordpress.org/support/users/monweb/)
 * (@monweb)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780093)
 * Just to say you forgot to tell me to add the data in the jQuery.ajax function
   in polls-js.dev.js 😉
    It work fine thank you.
 *  [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * (@digitalrub)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780094)
 * oh yeah, that would have been helpful…
 *  [mhoard8110](https://wordpress.org/support/users/mhoard8110/)
 * (@mhoard8110)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780109)
 * digitalrub,
 * can you shed more light on what monweb is referring to? which jQuery.ajax function
   do I add the data?
 *  [monweb](https://wordpress.org/support/users/monweb/)
 * (@monweb)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780110)
 * Hello mhoard8110,
 * The 2 jQuery.ajax functions you have to modify are in the “// Process Poll (User
   Click “Vote” Button)” section (line 80/100).
    You just have to add `+ '&pollip_name
   =' + pollip_name + '&pollip_email=' + pollip_email etc.` after `poll_id + '_nonce
   =' + poll_nonce` into the functions.
 *  [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * (@digitalrub)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780111)
 * Yeah, that’s it. Thanks, monweb.
 *  [mhoard8110](https://wordpress.org/support/users/mhoard8110/)
 * (@mhoard8110)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780118)
 * Thanks for the reply monweb. Another quick question. What about making these 
   fields required.
 *  [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * (@digitalrub)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780119)
 * this is how i did it:
 * you’ll need to add alerts to the wp-polls. php
 *     ```
       wp_localize_script('wp-polls', 'pollsL10n', array(
       		'ajax_url' => admin_url('admin-ajax.php', (is_ssl() ? 'https' : 'http')),
       		'text_wait' => __('Your last request is still being processed. Please wait a while ...', 'wp-polls'),
       		'text_valid' => __('Please choose a valid poll answer.', 'wp-polls'),
       		'text_name' => __('Please enter your name.', 'wp-polls'),
       		'text_tandc' => __('Please accept the terms and conditions.', 'wp-polls'),
       		'text_email' => __('Please enter a valid email address.', 'wp-polls'),
       		'text_carrier' => __('Please enter your current mobile carrier.', 'wp-polls'),
       		'text_multiple' => __('Maximum number of choices allowed: ', 'wp-polls'),
       		'show_loading' => intval($poll_ajax_style['loading']),
       		'show_fading' => intval($poll_ajax_style['fading'])
       	));
       ```
   
 * and then in polls-js
 *     ```
       if(poll_multiple_ans > 0) {
       			if(poll_multiple_ans_count > 0 && poll_multiple_ans_count <= poll_multiple_ans) {
       				poll_answer_id = poll_answer_id.substring(0, (poll_answer_id.length-1));
       				poll_process();
       			} else if(poll_multiple_ans_count == 0) {
       				set_is_being_voted(false);
       				alert(pollsL10n.text_valid);
       			} else {
       				set_is_being_voted(false);
       				alert(pollsL10n.text_multiple + ' ' + poll_multiple_ans);
       			}
       		} else {
       			 if(pollip_name == '') {
       				set_is_being_voted(false);
       				var name_alert = pollsL10n.text_name + "\n";
       			} else{var name_alert = ''}
   
       			if(pollip_email == '') {
       				set_is_being_voted(false);
       				var email_alert = pollsL10n.text_email + "\n";
       			} else{var email_alert = ''}
   
       			if(pollip_carrier == '') {
       				set_is_being_voted(false);
       				var carrier_alert = pollsL10n.text_carrier + "\n";
       			} else{var carrier_alert = ''}
   
       			if(pollip_rules !== 1) {
       				set_is_being_voted(false);
       				var tandc_alert = pollsL10n.text_tandc;
       			} else{var tandc_alert = ''}
   
       			if(poll_answer_id > 0 && pollip_name !== '' && pollip_email !== '' && pollip_carrier !== '' && pollip_rules == 1) {
       				poll_process();
       			} else {
       				set_is_being_voted(false);
       				alert(pollsL10n.text_valid + "\n" + name_alert + email_alert +  carrier_alert + tandc_alert);
       			}
       		}
       	} else {
       		alert(pollsL10n.text_wait);
       	}
       }
       ```
   

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

The topic ‘[Plugin: WP-Polls] Need help with adding Input Text field’ is closed 
to new replies.

 * ![](https://ps.w.org/wp-polls/assets/icon.svg?rev=977996)
 * [WP-Polls](https://wordpress.org/plugins/wp-polls/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-polls/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-polls/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-polls/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-polls/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-polls/reviews/)

 * 14 replies
 * 6 participants
 * Last reply from: [digitalrub](https://wordpress.org/support/users/digitalrub/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-polls-need-help-with-adding-input-text-field/#post-2780119)
 * Status: resolved