Nonces and Capability Checks: Writing WordPress Code That Cannot Be CSRF’d
Two lines of code, a nonce check and a capability check, close most of the privilege escalation and cross-site request forgery holes found in custom WordPress plugins and themes. Here is how to use them correctly, every time.