In my callback function (the one which output HTML for forms) of add_meta_box, I am using

wp_nonce_field( 'uniqueid', 'my_nonce' )

Now in saving function, I am using this at top to verify nonce

check_admin_referer( 'uniqueid', 'my_nonce' )

But due to this, I am getting below error as soon as I hit the Add New button
Are you sure you want to do this? (Its 403 default error message )

For now I am using wp_verify_nonce, but I don't understand why above code is not working?
Note: I am adding this meta box to a custom post type


Now in saving function ...

in which hook ? if you do this in "save_post_CPT", it doesn't work because this hook is called a first time a the object creation

then you have to do this :

add_action("save_post_CPT", function ($object_ID, \WP_Post $object, $update) {

    if (!$update) {

        // new object, here you can define default values



    if (isset($_REQUEST["uniqueid"])) {

            , "my_nonce"

        // saving informations of the metabox


    // here the code when the object is put in the trash or with quick edit e.g.

}, 10, 3);
  • Thank you, It Works. Can I get further reference of this implementation so that I can learn in more depth ? – sanjay ojha Apr 29 '17 at 15:43

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.