function hocwp_widget_subscribe_ajax_callback() { $use_captcha = (bool) hocwp_get_method_value('use_captcha'); $captcha_code = hocwp_get_method_value('captcha'); $email = hocwp_get_method_value('email'); $name = hocwp_get_method_value('name'); $phone = hocwp_get_method_value('phone'); $register = (bool) hocwp_get_method_value('register'); $result = array('success' => false, 'message' => hocwp_build_message(hocwp_text_error_default(), 'danger')); $captcha_valid = true; if ($use_captcha) { $captcha = new HOCWP_Captcha(); $captcha_valid = $captcha->check($captcha_code); } $re_verify = false; $query = hocwp_get_post_by_meta('subscriber_email', $email, array('post_type' => 'hocwp_subscriber')); if ($query->have_posts()) { $subscriber = array_shift($query->posts); $verified = hocwp_get_post_meta('subscriber_verified', $subscriber->ID); if (1 != $verified) { $re_verify = true; } } if ($captcha_valid) { if (is_email($email)) { $active_key = hocwp_generate_reset_key(); $verify_link = hocwp_generate_verify_link($active_key); if ($re_verify) { hocwp_send_mail_verify_email_subscription(hocwp_text_email_subject_verify_subscription(), $email, $verify_link); $result['success'] = true; $result['message'] = hocwp_build_message(hocwp_text_success_register_and_verify_email(), 'success'); } else { if ($query->have_posts() || $register && email_exists($email)) { $result['message'] = hocwp_build_message(hocwp_text_error_email_exists(), 'danger'); } else { $post_title = ''; if (!empty($name)) { $post_title .= $name; } if (empty($post_title)) { $post_title = $email; } else { $post_title .= ' - ' . $email; } $post_data = array('post_type' => 'hocwp_subscriber', 'post_title' => $post_title, 'post_status' => 'publish'); $post_id = hocwp_insert_post($post_data); if (hocwp_id_number_valid($post_id)) { update_post_meta($post_id, 'subscriber_name', $name); update_post_meta($post_id, 'subscriber_email', $email); update_post_meta($post_id, 'subscriber_phone', $phone); update_post_meta($post_id, 'subscriber_verified', 0); update_post_meta($post_id, 'subscriber_active_key', $active_key); if ($register) { $password = wp_generate_password(); $user_data = array('username' => $email, 'email' => $email, 'password' => $password); $user_id = hocwp_add_user($user_data); if (hocwp_id_number_valid($user_id)) { wp_send_new_user_notifications($user_id); update_post_meta($post_id, 'subscriber_user', $user_id); update_user_meta($user_id, 'subscriber_id', $post_id); } } hocwp_send_mail_verify_email_subscription(hocwp_text_email_subject_verify_subscription(), $email, $verify_link); $result['success'] = true; $result['message'] = hocwp_build_message(hocwp_text_success_register_and_verify_email(), 'success'); } } } } else { $result['message'] = hocwp_build_message(hocwp_text_error_email_not_valid(), 'danger'); } } else { $result['message'] = hocwp_build_message(hocwp_text_error_captcha_not_valid(), 'danger'); } wp_send_json($result); }
/** * Create/update an employee * * @return void */ public function employee_create() { $this->verify_nonce('wp-erp-hr-employee-nonce'); // @TODO: check permission unset($_POST['_wp_http_referer']); unset($_POST['_wpnonce']); unset($_POST['action']); $posted = array_map('strip_tags_deep', $_POST); $posted['type'] = 'customer'; $employee_id = erp_hr_employee_create($posted); if (is_wp_error($employee_id)) { $this->send_error($employee_id->get_error_message()); } $employee = new Employee($employee_id); $data = $employee->to_array(); $data['work']['joined'] = $employee->get_joined_date(); $data['work']['type'] = $employee->get_type(); $data['url'] = $employee->get_details_url(); if (isset($posted['user_notification']) && $posted['user_notification'] == 'on') { wp_send_new_user_notifications($employee_id); } $this->send_success($data); }
function user_register() { check_ajax_referer('wpuf_form_add'); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; $form_vars = $this->get_input_fields($form_id); $form_settings = wpuf_get_form_settings($form_id); list($user_vars, $taxonomy_vars, $meta_vars) = $form_vars; // search if rs captcha is there if ($this->search($user_vars, 'input_type', 'really_simple_captcha')) { $this->validate_rs_captcha(); } // check recaptcha if ($this->search($user_vars, 'input_type', 'recaptcha')) { $this->validate_re_captcha(); } $has_username_field = false; $username = ''; $user_email = ''; $firstname = ''; $lastname = ''; // don't let to be registered if no email address given if (!isset($_POST['user_email'])) { $this->send_error(__('An Email address is required', 'wpuf')); } // if any username given, check if it exists if ($this->search($user_vars, 'name', 'user_login')) { $has_username_field = true; $username = sanitize_user(trim($_POST['user_login'])); if (username_exists($username)) { $this->send_error(__('Username already exists.', 'wpuf')); } } // if any email address given, check if it exists if ($this->search($user_vars, 'name', 'user_email')) { $user_email = trim($_POST['user_email']); if (email_exists($user_email)) { $this->send_error(__('E-mail address already exists.', 'wpuf')); } } // if there isn't any username field in the form, lets guess a username if (!$has_username_field) { $username = $this->guess_username($user_email); } if (!validate_username($username)) { $this->send_error(__('Username is not valid', 'wpuf')); } // verify password if ($pass_element = $this->search($user_vars, 'name', 'password')) { $pass_element = current($pass_element); $password = $_POST['pass1']; $password_repeat = isset($_POST['pass2']) ? $_POST['pass2'] : false; // min length check if (strlen($password) < intval($pass_element['min_length'])) { $this->send_error(sprintf(__('Password must be %s character long', 'wpuf'), $pass_element['min_length'])); } // repeat password check if ($password != $password_repeat && $password_repeat !== false) { $this->send_error(__('Password didn\'t match', 'wpuf')); } } else { $password = wp_generate_password(); } // default WP registration hook $errors = new WP_Error(); do_action('register_post', $username, $user_email, $errors); $errors = apply_filters('registration_errors', $errors, $username, $user_email); if ($errors->get_error_code()) { $this->send_error($errors->get_error_message()); } // seems like we don't have any error. Lets register the user $user_id = wp_create_user($username, $password, $user_email); if (is_wp_error($user_id)) { $this->send_error($user_id->get_error_message()); } else { $userdata = array('ID' => $user_id, 'first_name' => $this->search($user_vars, 'name', 'first_name') ? $_POST['first_name'] : '', 'last_name' => $this->search($user_vars, 'name', 'last_name') ? $_POST['last_name'] : '', 'nickname' => $this->search($user_vars, 'name', 'nickname') ? $_POST['nickname'] : '', 'user_url' => $this->search($user_vars, 'name', 'user_url') ? $_POST['user_url'] : '', 'description' => $this->search($user_vars, 'name', 'description') ? $_POST['description'] : '', 'role' => $form_settings['role']); $user_id = wp_update_user(apply_filters('wpuf_register_user_args', $userdata)); if ($user_id) { // update meta fields $this->update_user_meta($meta_vars, $user_id); // send user notification or email verification if (isset($form_settings['enable_email_verification']) && $form_settings['enable_email_verification'] != 'yes') { wp_send_new_user_notifications($user_id); } else { $this->send_verification_mail($user_id, $user_email); } do_action('wpuf_after_register', $user_id, $userdata, $form_id, $form_settings); //redirect URL $show_message = false; $redirect_to = ''; if ($form_settings['redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['page_id']); } elseif ($form_settings['redirect_to'] == 'url') { $redirect_to = $form_settings['url']; } elseif ($form_settings['redirect_to'] == 'same') { $show_message = true; } else { $redirect_to = get_permalink($post_id); } // send the response $response = array('success' => true, 'post_id' => $user_id, 'redirect_to' => $redirect_to, 'show_message' => $show_message, 'message' => isset($form_settings['enable_email_verification']) && $form_settings['enable_email_verification'] == 'yes' ? __('Please check your email for activation link', 'wpuf') : $form_settings['message']); $autologin_after_registration = wpuf_get_option('autologin_after_registration', 'wpuf_profile'); if ($autologin_after_registration == 'on') { wp_set_current_user($user_id); wp_set_auth_cookie($user_id); } $response = apply_filters('wpuf_user_register_redirect', $response, $user_id, $userdata, $form_id, $form_settings); wpuf_clear_buffer(); echo json_encode($response); exit; } // endif } wpuf_clear_buffer(); echo json_encode(array('success' => false, 'error' => __('Something went wrong', 'wpuf'))); exit; }
/** * New/Edit post submit handler * * @return void */ function submit_post() { check_ajax_referer('wpuf_form_add'); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; $form_vars = $this->get_input_fields($form_id); $form_settings = wpuf_get_form_settings($form_id); list($post_vars, $taxonomy_vars, $meta_vars) = $form_vars; // don't check captcha on post edit if (!isset($_POST['post_id'])) { // search if rs captcha is there if ($this->search($post_vars, 'input_type', 'really_simple_captcha')) { $this->validate_rs_captcha(); } // check recaptcha if ($this->search($post_vars, 'input_type', 'recaptcha')) { $no_captcha = ''; if (isset($_POST["g-recaptcha-response"])) { $no_captcha = 1; } else { $no_captcha = 0; } $this->validate_re_captcha($no_captcha); } } $is_update = false; $post_author = null; $default_post_author = wpuf_get_option('default_post_owner', 'wpuf_general', 1); // Guest Stuffs: check for guest post if (!is_user_logged_in()) { if ($form_settings['guest_post'] == 'true' && $form_settings['guest_details'] == 'true') { $guest_name = trim($_POST['guest_name']); $guest_email = trim($_POST['guest_email']); // is valid email? if (!is_email($guest_email)) { $this->send_error(__('Invalid email address.', 'wpuf')); } // check if the user email already exists $user = get_user_by('email', $guest_email); if ($user) { // $post_author = $user->ID; echo json_encode(array('success' => false, 'error' => __("You already have an account in our site. Please login to continue.\n\nClicking 'OK' will redirect you to the login page and you will lost the form data.\nClick 'Cancel' to stay at this page.", 'wpuf'), 'type' => 'login', 'redirect_to' => wp_login_url(get_permalink($_POST['page_id'])))); exit; } else { // user not found, lets register him // username from email address $username = $this->guess_username($guest_email); $user_pass = wp_generate_password(12, false); $errors = new WP_Error(); do_action('register_post', $username, $guest_email, $errors); $user_id = wp_create_user($username, $user_pass, $guest_email); // if its a success and no errors found if ($user_id && !is_wp_error($user_id)) { update_user_option($user_id, 'default_password_nag', true, true); //Set up the Password change nag. if (class_exists('Theme_My_Login_Custom_Email')) { do_action('tml_new_user_registered', $user_id, $user_pass); } else { wp_send_new_user_notifications($user_id); } // update display name to full name wp_update_user(array('ID' => $user_id, 'display_name' => $guest_name)); $post_author = $user_id; } else { //something went wrong creating the user, set post author to the default author $post_author = $default_post_author; } } // guest post is enabled and details are off } elseif ($form_settings['guest_post'] == 'true' && $form_settings['guest_details'] == 'false') { $post_author = $default_post_author; } // the user must be logged in already } else { $post_author = get_current_user_id(); } $postarr = array('post_type' => $form_settings['post_type'], 'post_status' => isset($form_settings['post_status']) ? $form_settings['post_status'] : 'publish', 'post_author' => $post_author, 'post_title' => isset($_POST['post_title']) ? trim($_POST['post_title']) : '', 'post_content' => isset($_POST['post_content']) ? trim($_POST['post_content']) : '', 'post_excerpt' => isset($_POST['post_excerpt']) ? trim($_POST['post_excerpt']) : ''); //if date is set and assigned as publish date if (isset($_POST['wpuf_is_publish_time'])) { if (isset($_POST[$_POST['wpuf_is_publish_time']]) && !empty($_POST[$_POST['wpuf_is_publish_time']])) { $postarr['post_date'] = date('Y-m-d H:i:s', strtotime(str_replace(array(':', '/'), '-', $_POST[$_POST['wpuf_is_publish_time']]))); } } if (isset($_POST['category'])) { $category = $_POST['category']; $postarr['post_category'] = is_array($category) ? $category : array($category); if (!is_array($category) && is_string($category)) { $category_strings = explode(',', $category); $cat_ids = array(); foreach ($category_strings as $key => $each_cat_string) { $cat_ids[] = get_cat_ID(trim($each_cat_string)); $postarr['post_category'] = $cat_ids; } } } if (isset($_POST['tags'])) { $postarr['tags_input'] = explode(',', $_POST['tags']); } // if post_id is passed, we update the post if (isset($_POST['post_id'])) { $is_update = true; $postarr['ID'] = $_POST['post_id']; $postarr['post_date'] = $_POST['post_date']; $postarr['comment_status'] = $_POST['comment_status']; $postarr['post_author'] = $_POST['post_author']; $postarr['post_parent'] = get_post_field('post_parent', $_POST['post_id']); if ($form_settings['edit_post_status'] == '_nochange') { $postarr['post_status'] = get_post_field('post_status', $_POST['post_id']); } else { $postarr['post_status'] = $form_settings['edit_post_status']; } } else { if (isset($form_settings['comment_status'])) { $postarr['comment_status'] = $form_settings['comment_status']; } } // check the form status, it might be already a draft // in that case, it already has the post_id field // so, WPUF's add post action/filters won't work for new posts if (isset($_POST['wpuf_form_status']) && $_POST['wpuf_form_status'] == 'new') { $is_update = false; } // set default post category if it's not been set yet and if post type supports if (!isset($postarr['post_category']) && isset($form_settings['default_cat']) && is_object_in_taxonomy($form_settings['post_type'], 'category')) { $postarr['post_category'] = array($form_settings['default_cat']); } // validation filter if ($is_update) { $error = apply_filters('wpuf_update_post_validate', ''); } else { $error = apply_filters('wpuf_add_post_validate', ''); } if (!empty($error)) { $this->send_error($error); } // ############ It's Time to Save the World ############### if ($is_update) { $postarr = apply_filters('wpuf_update_post_args', $postarr, $form_id, $form_settings, $form_vars); } else { $postarr = apply_filters('wpuf_add_post_args', $postarr, $form_id, $form_settings, $form_vars); } $post_id = wp_insert_post($postarr); if ($post_id) { self::update_post_meta($meta_vars, $post_id); // if user has a subscription pack $user_wpuf_subscription_pack = get_user_meta(get_current_user_id(), '_wpuf_subscription_pack', true); if (!empty($user_wpuf_subscription_pack) && isset($user_wpuf_subscription_pack['_enable_post_expiration']) && isset($user_wpuf_subscription_pack['expire']) && strtotime($user_wpuf_subscription_pack['expire']) >= time()) { $expire_date = date('Y-m-d', strtotime("+" . $user_wpuf_subscription_pack['_post_expiration_time'])); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $user_wpuf_subscription_pack['_expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($user_wpuf_subscription_pack['_enable_mail_after_expired']) && $user_wpuf_subscription_pack['_enable_mail_after_expired'] == 'on') { $post_expiration_message = $user_wpuf_subscription_pack['_post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } elseif (!empty($user_wpuf_subscription_pack) && isset($user_wpuf_subscription_pack['expire']) && strtotime($user_wpuf_subscription_pack['expire']) <= time()) { if (isset($form_settings['expiration_settings']['enable_post_expiration'])) { $expire_date = date('Y-m-d', strtotime("+" . $form_settings['expiration_settings']['expiration_time_value'] . ' ' . $form_settings['expiration_settings']['expiration_time_type'] . "")); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $form_settings['expiration_settings']['expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($form_settings['expiration_settings']['enable_mail_after_expired']) && $form_settings['expiration_settings']['enable_mail_after_expired'] == 'on') { $post_expiration_message = $form_settings['expiration_settings']['post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } } elseif (empty($user_wpuf_subscription_pack)) { if (isset($form_settings['expiration_settings']['enable_post_expiration'])) { $expire_date = date('Y-m-d', strtotime("+" . $form_settings['expiration_settings']['expiration_time_value'] . ' ' . $form_settings['expiration_settings']['expiration_time_type'] . "")); update_post_meta($post_id, $this->post_expiration_date, $expire_date); // save post status after expiration $expired_post_status = $form_settings['expiration_settings']['expired_post_status']; update_post_meta($post_id, $this->expired_post_status, $expired_post_status); // if mail active if (isset($form_settings['expiration_settings']['enable_mail_after_expired']) && $form_settings['expiration_settings']['enable_mail_after_expired'] == 'on') { $post_expiration_message = $form_settings['expiration_settings']['post_expiration_message']; update_post_meta($post_id, $this->post_expiration_message, $post_expiration_message); } } } // set the post form_id for later usage update_post_meta($post_id, self::$config_id, $form_id); // save post formats if have any if (isset($form_settings['post_format']) && $form_settings['post_format'] != '0') { if (post_type_supports($form_settings['post_type'], 'post-formats')) { set_post_format($post_id, $form_settings['post_format']); } } // find our if any images in post content and associate them if (!empty($postarr['post_content'])) { $dom = new DOMDocument(); @$dom->loadHTML($postarr['post_content']); $images = $dom->getElementsByTagName('img'); if ($images->length) { foreach ($images as $img) { $url = $img->getAttribute('src'); $url = str_replace(array('"', "'", "\\"), '', $url); $attachment_id = wpuf_get_attachment_id_from_url($url); if ($attachment_id) { wpuf_associate_attachment($attachment_id, $post_id); } } } } // save any custom taxonomies $woo_attr = array(); foreach ($taxonomy_vars as $taxonomy) { if (isset($_POST[$taxonomy['name']])) { if (is_object_in_taxonomy($form_settings['post_type'], $taxonomy['name'])) { $tax = $_POST[$taxonomy['name']]; // if it's not an array, make it one if (!is_array($tax)) { $tax = array($tax); } if ($taxonomy['type'] == 'text') { $hierarchical = array_map('trim', array_map('strip_tags', explode(',', $_POST[$taxonomy['name']]))); wp_set_object_terms($post_id, $hierarchical, $taxonomy['name']); // woocommerce check if (isset($taxonomy['woo_attr']) && $taxonomy['woo_attr'] == 'yes' && !empty($_POST[$taxonomy['name']])) { $woo_attr[sanitize_title($taxonomy['name'])] = $this->woo_attribute($taxonomy); } } else { if (is_taxonomy_hierarchical($taxonomy['name'])) { wp_set_post_terms($post_id, $_POST[$taxonomy['name']], $taxonomy['name']); // woocommerce check if (isset($taxonomy['woo_attr']) && $taxonomy['woo_attr'] == 'yes' && !empty($_POST[$taxonomy['name']])) { $woo_attr[sanitize_title($taxonomy['name'])] = $this->woo_attribute($taxonomy); } } else { if ($tax) { $non_hierarchical = array(); foreach ($tax as $value) { $term = get_term_by('id', $value, $taxonomy['name']); if ($term && !is_wp_error($term)) { $non_hierarchical[] = $term->name; } } wp_set_post_terms($post_id, $non_hierarchical, $taxonomy['name']); } } // hierarchical } // is text } // is object tax } // isset tax } // if a woocommerce attribute if ($woo_attr) { update_post_meta($post_id, '_product_attributes', $woo_attr); } if ($is_update) { // plugin API to extend the functionality do_action('wpuf_edit_post_after_update', $post_id, $form_id, $form_settings, $form_vars); //send mail notification if (isset($form_settings['notification']) && $form_settings['notification']['edit'] == 'on') { $mail_body = $this->prepare_mail_body($form_settings['notification']['edit_body'], $post_author, $post_id); wp_mail($form_settings['notification']['edit_to'], $form_settings['notification']['edit_subject'], $mail_body); } } else { // plugin API to extend the functionality do_action('wpuf_add_post_after_insert', $post_id, $form_id, $form_settings, $form_vars); // send mail notification if (isset($form_settings['notification']) && $form_settings['notification']['new'] == 'on') { $mail_body = $this->prepare_mail_body($form_settings['notification']['new_body'], $post_author, $post_id); wp_mail($form_settings['notification']['new_to'], $form_settings['notification']['new_subject'], $mail_body); } } //redirect URL $show_message = false; $redirect_to = false; if ($is_update) { if ($form_settings['edit_redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['edit_page_id']); } elseif ($form_settings['edit_redirect_to'] == 'url') { $redirect_to = $form_settings['edit_url']; } elseif ($form_settings['edit_redirect_to'] == 'same') { $redirect_to = add_query_arg(array('pid' => $post_id, '_wpnonce' => wp_create_nonce('wpuf_edit'), 'msg' => 'post_updated'), get_permalink($_POST['page_id'])); } else { $redirect_to = get_permalink($post_id); } } else { if ($form_settings['redirect_to'] == 'page') { $redirect_to = get_permalink($form_settings['page_id']); } elseif ($form_settings['redirect_to'] == 'url') { $redirect_to = $form_settings['url']; } elseif ($form_settings['redirect_to'] == 'same') { $show_message = true; } else { $redirect_to = get_permalink($post_id); } } // send the response $response = array('success' => true, 'redirect_to' => $redirect_to, 'show_message' => $show_message, 'message' => $form_settings['message']); if ($is_update) { $response = apply_filters('wpuf_edit_post_redirect', $response, $post_id, $form_id, $form_settings); } else { $response = apply_filters('wpuf_add_post_redirect', $response, $post_id, $form_id, $form_settings); } wpuf_clear_buffer(); echo json_encode($response); exit; } $this->send_error(__('Something went wrong', 'wpuf')); }
/** * Handles registering a new user. * * @param string $user_login User's username for logging in * @param string $user_email User's email address to send password and add * @return int|WP_Error Either user's ID or error on failure. */ function wpuf_register_new_user($user_login, $user_email, $role) { $errors = new WP_Error(); $sanitized_user_login = sanitize_user($user_login); $user_email = apply_filters('user_registration_email', $user_email); // Check the username if ($sanitized_user_login == '') { $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.')); } elseif (!validate_username($user_login)) { $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.')); $sanitized_user_login = ''; } elseif (username_exists($sanitized_user_login)) { $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); } // Check the e-mail address if ($user_email == '') { $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.')); } elseif (!is_email($user_email)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.')); $user_email = ''; } elseif (email_exists($user_email)) { $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.')); } do_action('register_post', $sanitized_user_login, $user_email, $errors); $errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email); if ($errors->get_error_code()) { return $errors; } $user_pass = wp_generate_password(12, false); //$user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email ); $userdata = array('user_login' => $sanitized_user_login, 'user_email' => $user_email, 'user_pas' => $user_pass, 'role' => $role); $user_id = wp_insert_user($userdata); if (!$user_id) { $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email'))); return $errors; } update_user_option($user_id, 'default_password_nag', true, true); //Set up the Password change nag. wp_send_new_user_notifications($user_id); return $user_id; }
/** * Check in activation of user registration * * @since 2.2 */ function activation_user_registration() { if (!isset($_GET['wpuf_registration_activation']) && empty($_GET['wpuf_registration_activation'])) { return; } if (!isset($_GET['id']) && empty($_GET['id'])) { return; } $user_id = intval($_GET['id']); $activation_key = $_GET['wpuf_registration_activation']; if (get_user_meta($user_id, '_wpuf_activation_key', true) != $activation_key) { return; } delete_user_meta($user_id, '_wpuf_user_active'); delete_user_meta($user_id, '_wpuf_activation_key'); // show activation message add_filter('wp_login_errors', array($this, 'user_activation_message')); wp_send_new_user_notifications($user_id); do_action('wpuf_user_activated', $user_id); }