I assume the issue is that your form targets an external file, where WordPress isn’t properly loaded to access the API.
WordPress has a handler built in that you can use to process POST requests, via the admin_post
action:
Example form with hidden action
field:
<form action="<?php echo admin_url( 'admin-post.php' ); ?>" method="post">
<input type="hidden" name="action" value="add_foobar">
<input type="hidden" name="data" value="somedata">
<input type="submit" value="Submit">
</form>
Example action, mapped to action
passed from form:
add_action( 'admin_post_add_foobar', 'prefix_admin_add_foobar' );
//this next action version allows users not logged in to submit requests
add_action( 'admin_post_nopriv_add_foobar', 'prefix_admin_add_foobar' );
function prefix_admin_add_foobar() {
status_header(200);
// load your processing.php file
die();
}
WordPress will be loaded in this context, giving you access to the API in your form processing code.