Help with time sensitive php function

I am trying to display a “Delete Post” link for front end users’ posts using the following code. I can’t get it to work and I don’t understand PHP well enough to fix it. Any suggestions would be appreciated. Thank you.

This code works, but I don’t know how to get the time check on it:

<?php if ($post->post_author == $current_user->ID) { ?>
   <p><a onclick="return confirm('Are you SURE you want to delete this post?')" href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p>

<?php } ?>

This is the code I am trying to use:

<div  class="post-delete"><span class="delete-post">
<?php if ( (int) get_the_date('U', get_the_ID()) > time() - 2800 && (is_user_logged_in() && $current_user->ID == $post->post_author)) {
    echo ' <p><a onclick="return confirm("Are you SURE you want to delete this post?");" href="<?php echo get_delete_post_link( $post->ID ) ?>">Delete post</a></p>';
}else{
?>
<style type="text/css">.post-delete{
display:none;
}</style>
<?php
}?>
</span></div>

Looking forward to any help. Thank you.

Read more here: Help with time sensitive php function

Leave a Reply

Your email address will not be published. Required fields are marked *