WordPress – updating plugin option on click by admin

I am trying to do something simple – essentially trying to create a notice to the admin of the website using my plugin. Alongside, I want to provide an option to dismiss the notice in case they do not want to see it anymore.

I cannot figure this out. Below is my code – but everytime I click on the button, it gives me thw wordpress error “are you sure you want to do this”..

Ay help/example will be awesome!


div class="Plugin_Admin_Notice notice notice-warning is-dismissible">
_e('<form action="options.php" method="post"><input type="hidden" name="option_page" value="plugin_options" /><input type="hidden" name="action" value="update" /><input type="hidden" id="_wpnonce" name="_wpnonce" value='. wp_create_nonce( 'add_option' ) .' /><input type="hidden" name="_wp_http_referer" value="/wp-admin/options-general.php?page=plugin" /><input type="text" name="plugin-notice" value="1"><input name="Submit" type="submit" value="Dont Show Anymore"></form>', 'Plugin_textdomain');



Any idea whatis wrong – I have a feeling that its something to do with wp_create_nonce, but not sure.

Read more here: WordPress – updating plugin option on click by admin

Leave a Reply

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