diff options
| Commit | 1c86fe831289eee3d3c2c963885fd553f40f81d2 (patch) | |
|---|---|---|
| Author | 2020-07-15 20:43:05 +0300 | |
| Committer | 2020-07-15 20:43:05 +0300 | |
| Files | 1dc3d183affddf9c040eba8b9ec1e60c9e002d90 /wp-content/plugins/dx-users/register-user-class.php | |
| tues-interns-2020-feature/offers-grid.tar tues-interns-2020-feature/offers-grid.tar.gz tues-interns-2020-feature/offers-grid.zip | ||
| Parent | 333668c49e98cdfc84cf0702f289bd149fc5fd25 (diff) | |
[fix] bring changes from master feature/offers-grid
1 files changed, 31 insertions, 0 deletions
| -rw-r--r-- | wp-content/plugins/dx-users/register-user-class.php | 31 |
diff --git a/wp-content/plugins/dx-users/register-user-class.php b/wp-content/plugins/dx-users/register-user-class.php new file mode 100644 index 0000000..bbadf3c --- /dev/null +++ b/wp-content/plugins/dx-users/register-user-class.php @@ -0,0 +1,31 @@ +<?php +class RegisterUser { + function init() { + add_action( 'admin_post_nopriv_process_register', array( $this, 'process_register_data' )); + } + + function process_register_data() { + if( username_exists( sanitize_text_field( $_POST['password'] ) ) ) { + wp_die( 'User already exists!' ); + } + + $user_data = array( + 'user_pass' => sanitize_text_field( $_POST['password'] ), + 'user_login' => sanitize_text_field( $_POST['email'] ), + 'user_email' => sanitize_text_field( $_POST['email'] ), + 'display_name' => sanitize_text_field( $_POST['name'] ), + ); + + if( ! is_email( $user_data['user_email'] ) ) { + wp_die( 'Invaid email address!' ); + } + + $user_id = wp_insert_user( $user_data ); + + if( is_wp_error( $user_id ) ) { + wp_die( $user_id->get_error_message() ); + } + + wp_redirect( home_url() ); exit; + } +} |
