title: wordpress, ajax = no go
body: <p>I asked a similar question with good advise to help me, but i have run into another problem with the same code. What I am looking to do is simply click a button on a users profile and change the default "0", meaning they're not banned, to a "1". Before I was using a hook and a "do_action" with no problems, now I am trying to use ajax. I will start by posting my code. </p>
  
  <p><strong>FUNCTION</strong></p>
  
  <pre><code>add_action( 'wp_ajax_remove_account', 'remove_account' );
  function remove_account() {
      global $wpdb;
      global $current_user;
      $author = get_queried_object();
      $uid = $author-&gt;ID;
      $user = $current_user-&gt;ID;
      $wpdb-&gt;query( $wpdb-&gt;prepare( "UPDATE $wpdb-&gt;users SET removed = '%d' WHERE ID = '%d'", '1', $user ));
      wp_die();
  }
  </code></pre>
  
  <p><strong>AJAX</strong></p>
  
  <pre><code>jQuery(document).ready(function($) {
      $('.wordpress-ajax-form').on('submit', function(e) {
      e.preventDefault();
      var $form = $(this);
      $.post($form.attr('action'), $form.serialize(), function(data) {
      }, 'json');
  }); });
  </code></pre>
  
  <p><strong>FORM</strong></p>
  
  <pre><code>&lt;form class="wordpress-ajax-form" method="post" action="&lt;?php echo        AJAX_URL; ?&gt;" &gt;
  &lt;input type="hidden" name="action" value="remove_account" &gt;&lt;br&gt;
  &lt;center&gt;&lt;button id="msgbutton"&gt;Remove Account&lt;/button&gt;&lt;/center&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The above will work fine, however if I change </p>
  
  <pre><code>$wpdb-&gt;query( $wpdb-&gt;prepare( "UPDATE $wpdb-&gt;users SET removed = '%d' WHERE ID = '%d'", '1', $user ));
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$wpdb-&gt;query( $wpdb-&gt;prepare( "UPDATE $wpdb-&gt;users SET removed = '%d' WHERE ID = '%d'", '1', $uid ));
  </code></pre>
  
  <p>to get the user id of the profile I'm looking at, it doesn't work.</p>
  
  <p>I added </p>
  
  <pre><code>$author = get_queried_object();
  echo $author-&gt;ID;`
  </code></pre>
  
  <p>to my header and it gave me back the user id of the profile i was looking at so I know that code works. Any help is appreciated. </p>