Trying to:
Submit form using admin-ajax.php to update post data from 'draft' status to 'publish' status and add custom meta field for filter type.
Form contents:
<form action="<?php echo admin_url( 'admin-ajax.php' ) ?>" method="post">
<?php wp_nonce_field( 'submit_filter', 'my_filter_nonce' ); ?>
<div class="small-6 medium-3 large-3 columns">
<div class="card">
<img src="<?php echo get_the_post_thumbnail_url( $posts[0]->ID, 'thumbnail' ); ?>" class="" id="normal">
<div class="card-section">
<input type="submit" value="No Filter" name="normal">
</div>
</div>
</div>
</form>
Form action:
// process form actions
add_action( 'wp_ajax_nopriv_submit_filter', 'my_submission_filter' );
add_action( 'wp_ajax_submit_filter', 'my_submission_filter' );
function my_submission_filter() {
$postid = get_the_ID();
$post_data = array(
'ID' => $postid,
'post_status' => 'publish'
);
// add filter meta data
add_post_meta($postid, 'filter', $_POST['filter']);
// Update the post into the database
wp_update_post( $my_post );
// redirect back to site to see post
wp_redirect( site_url());
die();
}
Results:
Blank page with a "0" in the top right corner and no updates to post.
Would like:
Help making this work :)