here i'm trying on submitting to delete the post in process.. i've tried without the hidden input aswell as doing the if isset on the redirecting page when form's submit. all 3 ways failed.
if(isset($_POST['postType'])
&& isset($_POST['idValue']))
{
$post_type = $_POST['postType'];
$id_post = $_POST['idValue'];
$postInfo = array(
'post_type' => $post_type,
'ID' => $id_post
);
wp_delete_post($postInfo, true);
}
if(isset($_GET['action']) && $_GET['action'] == "Supprimer")
{
?>
<div id="overlay">
<div id="SupprimerAnnonce">
<form method="post" action="<?php echo add_query_arg( 'action', 'Deleted', $_SERVER['HTTP_REFERER']); ?>">
<p>Êtes-vous sûr de vouloir supprimer</p>
<p><b><?php the_field('titre') ?></b></p>
<input type="submit" name="delete" value="Continuer"/>
<?php
$post_type = get_post_type( get_the_ID() );
$id_post = get_the_ID();
?>
<input type="hidden" name="idValue" value="<?php echo $id_post; ?>" readonly />
<input type="hidden" name="postType" value="<?php echo $post_type; ?>" readonly />
</form>
</div>
<a href="javascript:void(0)" onclick="document.getElementById('overlay').style.display='none';document.getElementById('fade').style.display='none'" title="Fermer">Fermer</a>
</div>
<div id="fade"></div>
<?php
}
Any tips ?
Thx
action.php
includeget_header();
etc?