title: WordPress REST API - Allow anyone to POST
body: <p>I am building an application on WordPress that requires a simple front end form where anyone can submit information that needs to be saved in the database. I am attempting to handle this through the REST API. (Due to the nature of the application, there can not be any redirection of the page when this information is submitted.)</p>
  
  <p>I have no problem setting up the REST API (v2) so that I can submit a post. It works great when I am logged into WordPress. When I try to fill out the form when I am not logged in to WordPress, I receive an error.</p>
  
  <blockquote>
    <p>Failed to load resource: the server responded with a status of 403 (Forbidden)</p>
  </blockquote>
  
  <p>How can I set the API to receive a POST from anyone without authentication?</p>
  
  <p>Here is my javascript:</p>
  
  <pre><code>$( '#post-submission-form' ).on( 'submit', function(e) {
      e.preventDefault();
      var title = $( '#post-submission-title' ).val();
      var excerpt = $( '#post-submission-excerpt' ).val();
      var content = $( '#post-submission-content' ).val();
      var status = 'draft';
  
      var data = {
          title: title,
          excerpt: excerpt,
          content: content
      };
  
      $.ajax({
          method: "POST",
          url: POST_SUBMITTER.root + 'wp/v2/posts',
          data: data,
          beforeSend: function ( xhr ) {
              //xhr.setRequestHeader( 'X-WP-Nonce', POST_SUBMITTER.nonce );
          },
          success : function( response ) {
              console.log( response );
              alert( POST_SUBMITTER.success );
          },
          fail : function( response ) {
              console.log( response );
              alert( POST_SUBMITTER.failure );
          }
  
      });
  
  });
  </code></pre>
  
  <p>Here is how I am initializing my javascript:</p>
  
  <pre><code>function holiday_scripts() {
  
      // Onload JS
      wp_enqueue_script( 'holiday-js', get_template_directory_uri() . '/js/holiday.js', array(), false, true );
  
      //localize data for script
      wp_localize_script( 'holiday-js', 'POST_SUBMITTER', array(
          'root' =&gt; esc_url_raw( rest_url() ),
          'nonce' =&gt; wp_create_nonce( 'wp_rest' ),
          'success' =&gt; __( 'Thanks for your submission!', 'your-text-domain' ),
          'failure' =&gt; __( 'Your submission could not be processed.', 'your-text-domain' ),
          'current_user_id' =&gt; 9
          )
       );
  }
  add_action( 'wp_enqueue_scripts', 'holiday_scripts' );
  </code></pre>
  
  <p>Does anyone have any idea on how to accomplish this?</p>
  
  <p>Thanks!</p>