Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

The ref feature

Peter Karman edited this page Oct 8, 2022 · 7 revisions

The ref feature

You can use the KSVotes ref feature to send a reference code to initiate a registration session.

Remember: to specify a particular language, prefix any URL patterns with the language:

There are two ways to use ref.

GET request

If you enter https://www.ksvotes.org/ref?ref=your-org into your browser, the your-org ref code will be saved and used for every registration until your browser is restarted.

You may use the alternate URL syntax https://www.ksvotes.org/r/your-org instead. The effect is the same.

POST request

You can host a form on your own server, in order to capture voter information before redirecting to KSVotes.org.

This example HTML snippet shows how you can create a form, gather input, and then redirect to KSVotes.

<html>
<body>
 <div>
  <h1>KSVotes.org test</h1>
   <form id="ksvotes" method="POST" action="https://www.ksvotes.org/ref?ref=wiki-example">
    <div>
     <input name="name_first" value="" > First Name
    </div>
    <div>
     <input name="name_last" value="" > Last Name
    </div>
    <div>
     <input name="dob" value="" placeholder="mm/dd/yyyy"> DOB
    </div>
    <div>
     <input name="email" value="" placeholder="[email protected]" type="email"> Email
    </div>
    <div>
     <input name="phone" value="" placeholder="555-555-5555" type="tel"> Phone
    </div>

    <button>Submit</button>
 </div>

 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
 <script>
   let $form = $('#ksvotes');
   $form.on('submit', function(ev, opts) {
     let options = opts || {};
     if (!options.payload_saved) {
       let $payload = $form.serialize();

       // pause our ksvotes form submit to save the data locally
       ev.preventDefault();

       // send the data to our own server
       $.ajax({
         method: 'POST', // IMPORTANT to keep PII out of your server logs
         data: $payload,
         complete: function(data) {
           // pick up where we left off and continue to ksvotes
           $(ev.currentTarget).trigger('submit', { 'payload_saved': true });
         }
       });
     } else {
       alert("Sending data to KSVotes!");
     }
   });
 </script>
</body>
</html>
Clone this wiki locally