how to redirect page after delete post inside a post page?

Question

so on theme single.php i want to put delete button so they can delete the post directly. After the post deleted then the page will redirect to profile page.

here’s the delete button html

<a class="edit-post" onclick="redirectFunction();" href="<?php bp_loggedinuser_link(); ?>articles/"> Delete </a>

and this is the script for delete the post

function redirectFunction(){
    <?php wp_delete_post(get_the_id()); ?>
}

the problem is when i click other link that show on page, it also trigger this function to delete the post.

please help or let me know if there’s any way better than this. thanks

0
, , Hend Ry 3 years 2020-06-06T21:10:22-05:00 0 Answers 90 views 0

Leave an answer

Browse
Browse