Skip to content

Instantly share code, notes, and snippets.

@igmoweb
Created November 29, 2017 14:04
Show Gist options
  • Save igmoweb/5daf7ed1862e390e8cf3c1df8e6bea65 to your computer and use it in GitHub Desktop.
Save igmoweb/5daf7ed1862e390e8cf3c1df8e6bea65 to your computer and use it in GitHub Desktop.
Ejemplo de plugin con CSRF
<?php
/**
* Plugin Name: Un ejemplo de plugin con un problema de CSRF
*/
add_action( 'init', 'maybe_delete_user' );
function maybe_delete_user() {
if ( isset( $_POST['action'] ) && $_POST['action'] === 'delete-user' ) {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$user_id = absint( $_POST['user_id'] );
wp_delete_user( $user_id );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment