title: Passing a form field to ajax, and then posting it via php
body: <p>I trying to modify Wordpress plugin. It uses a front-end form, processed with ajax/jquery to post submissions into various logs. I need to add an additional field, pass its value to the .js file and post the additional field as well.   </p>
  
  <p>So far I have added the additional field by hooking into an existing function. The field looks like this and is visible on the front end. </p>
  
  <pre><code>$description_input = '&lt;input type="text" id="custom_message" 
  name="custom_message" value="" class="transfer-description" 
  placeholder="Description" /&gt;';
  echo $description_input;
  </code></pre>
  
  <p>The form that this extra field is added into has existing fields: to, sender, recipient, amount, token, and a submit.</p>
  
  <p>What I don't understand is how to pass this extra field to the ajax function. </p>
  
  <p>The first part of the .js file that is processing the form looks like this: </p>
  
  <p>The developer has been helping me, or I'd never make it even this far... He added <code>'info'</code> and  <code>tinfo  : info</code> , which I think is supposed to handle the extra field. </p>
  
  <pre><code>jQuery(function($){
  // Transfer function
  var transfer_creds = function( to, creds, info, label ) {
  $.ajax({
  type : "POST",
  data : {
  action    : 'myc-transfer-creds',
  sender    : myC.user_id,
  recipient : to,
  amount    : creds,
  token     : myCRED.token,
  tinfo     : info
  },
  dataType : "JSON",
  url : myC.ajaxurl,
  ... (the rest of the .js here)
  </code></pre>
  
  <p>Then to insert the extra field into the log entries the developer was using this:</p>
  
  <pre><code>$transfer_message = '';
  if ( isset( $_POST['tinfo'] ) )
  $transfer_message = sanitize_text_field( $_POST['tinfo'] );
  </code></pre>
  
  <p>This is not the complete code, but seems to be the relevant part. So, my question again is how to send an additional form field to ajax, then posting that information via php? I'm not sure I've explained this properly, but thanks for the help.</p>