On using inspect element to check the 'href' attribute of 'Deactivate' links for the plugins listed on plugins.php page, I found that the url contains a wpnonce field with a certain value. I need to get this value. For eg,

<a href="plugins.php?action=deactivate&amp;plugin=my-custom-css%2Fmy-custom-css.php&amp;plugin_status=all&amp;paged=1&amp;s&amp;_wpnonce=08a2b0d940" title="Deactivate this plugin">Deactivate</a>

How do I get this value '08a2b0d940' as in the above link ?


That value is a random-ish string generated for one-time use with a lifespan of, if I remember correctly, 12 hours. I am not sure what you mean by "get" the value. Assuming you mean "generate the nonce" then...

You want wp_nonce_url or one of the related functions.

wp_nonce_url( $actionurl, $action, $name ); 

For example:

wp_nonce_url( 'http://www.google.com'); 

You can't regenerate the value if that is what you want but you could regex it out of the URL with PHP, circumstances permitting, or use Javascript to search the generated markup. Since I don't know why you are trying to do this, a solid answer is difficult.

  • I actually have no clue what to use to get the desired value. But will try ur suggestion ! – Navin Nagpal Sep 25 '13 at 14:41
  • That helped. Thanx ! – Navin Nagpal Sep 25 '13 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.