In one of our WP site whenever a user responds to a from or submits a request from a from, a draft post is created automatically. The link for the draft post is mailed to the administrator to edit the post before publishing.
Now the new requirement is to create a trash link also for the same post to be mailed to admin. The problem with the nonce is that it need to vbe verified before the same can be used.
I am able to create a trash link, but am unsure how to verify this link else it will throw an security error "Are you sure you want to do this?" and Please try again?
the codes used are
Edit code for post:
Trash code for the post:
The code used for creating the Trash link:
$nonce= wp_create_nonce ('my-nonce');
if (! wp_verify_nonce($nonce, 'my-nonce') ) die("Security check");
$elink = "\n\n Trash Link: http://www.somedomain.com/wp-admin/post.php?post=$post_id&action=trash&_wpnonce=$nonce \n\n\n";
The following code also been place in <form>
<?php wp_nonce_field('my-nonce'); ?>
Now the issue is trash link alongwith the nonce code is being generated, but when the link is created from mail it generated security error.
I think i have to embed some kind of code in link so that the nonce code is verified before it can be used?
Any thought or suggestion on how to create a trash link which can be mailed and can be used by just clicking the link rather that using from the WP-admin pages.