nonce - wp_nonce_url generating invalid links

admin2025-06-05  2

My goal is to allow users to delete posts they own from the front end. I have an API that returns some JSON along with a link to delete their post.

$delLink = wp_nonce_url( site_url() . "/wp-admin/post.php?action=trash&post=" . $post->ID, 'trash-' . $post->post_type . '_' . $post->ID);

This does return a url with a nonce

.php?post=338&action=trash&_wpnonce=983403d085

If I click this link it brings me to the 'posts' section of my admin panel without deleting the custom post in question.

But if I compare that to the link in my admin panel, the URL should be

.php?post=338&action=trash&_wpnonce=7337993b16

What am I doing wrong here?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749076282a316152.html

最新回复(0)