From 3f3721270df075abbe0dcc8eff391561a226ab60 Mon Sep 17 00:00:00 2001 From: champsupertramp Date: Tue, 21 Jun 2016 15:29:06 +0800 Subject: [PATCH] Add nonce in registration form --- core/um-register.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/um-register.php b/core/um-register.php index 62dfd1cd..7190e840 100644 --- a/core/um-register.php +++ b/core/um-register.php @@ -2,4 +2,24 @@ class UM_Register { + function __construct(){ + + add_action("um_after_register_fields", array( $this, 'add_nonce' ) ); + add_action("um_submit_form_register", array( $this, 'verify_nonce'), 1, 1); + } + + public function add_nonce(){ + wp_nonce_field( 'um_register_form' ); + } + + public function verify_nonce( $args ){ + global $ultimatemember; + + if ( ! wp_verify_nonce( $args['_wpnonce'], 'um_register_form' ) || empty( $args['_wpnonce'] ) || ! isset( $args['_wpnonce'] ) ) { + wp_die('Invalid Nonce.'); + } + + return $args; + } + } \ No newline at end of file