Created
November 29, 2017 14:46
-
-
Save igmoweb/8e547b086efba71dda89c05426e1ed45 to your computer and use it in GitHub Desktop.
Plugin sin CSRF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
if ( ! isset( $_POST['delete-user-nonce'] ) ) { | |
wp_die( '¿Qué haces?'); | |
} | |
if ( ! wp_verify_nonce( $_POST['delete-user-nonce'], 'delete-user' ) ) { | |
wp_die( '¿Qué haces?'); | |
} | |
$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