One button on admin page works but not two

I think I’ve solved the problem, there are 2 issues:

  1. You have 1 form for both buttons, submitting means submitting the entire form, so both buttons are submitted
  2. Your nonce/referrer checks appear to be incomplete

The second item is why you’re having issues, although server time issues could also factor in.

If we inspect your nonce and check closer:


...

check_admin_referer('thing_button_clicked')

...

wp_nonce_field('thing_button_clicked');

Notice that they only use the first parameter which is the action. They do not specify the name. This means that when you use wp_nonce_field, it will default too _nonce, resulting in <input type="hidden" name="_nonce"... which is a problem when you have 2 nonces.

So specify the second parameter, or switch to a singular nonce