Init action and refresh page after form action

My problem is that I can't refresh the page after a form action into a loop. In my case I have a listing post page where I can delete, archive, deliver posts through a modal form, row by row.

After asking a previous question here I've known that I should perform the form action through the init hook to make it run before headers are sent.

I've tried without success like this: In my functions.php

add_action('init', 'init_deliver'); //trying to run it before headers
function init_deliver($pid){
    //code to archive the post
    //update_post_meta etc...
}
add_action('deliver_post', 'delivered_action');
function delivered_action($pid) { 
    if(isset($_POST['deliver']))
    {   
        init_deliver($pid); //calling a the init function
    } ?
 div id="modal" class="modal fade" role="dialog"
     form method="post" 
        input id="deliver" type="submit" name="deliver" class="submit_green" style="width:100%; text-align:center;" /
     /form
 /div
}

And I call all this in my loop like this

a href="#" data-toggle="modal" data-target="#-modal"Deliver?/a
?php do_action("deliver_post", $pid); ? !--I pass here the post id $pid--

The post is delivered but the page doesn't refresh when I submit the form. It refreshes always the second time I reload it. I need instead that the page is immediately refreshed after form submitting. Can you please give me an example or drive me through it? Thanks.

Topic row-actions functions actions init forms Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.