/** * Handle reset password form. */ public static function process_reset_password() { $posted_fields = array('wc_reset_password', 'password_1', 'password_2', 'reset_key', 'reset_login', '_wpnonce'); foreach ($posted_fields as $field) { if (!isset($_POST[$field])) { return; } $posted_fields[$field] = $_POST[$field]; } if (!wp_verify_nonce($posted_fields['_wpnonce'], 'reset_password')) { return; } $user = WC_Shortcode_My_Account::check_password_reset_key($posted_fields['reset_key'], $posted_fields['reset_login']); if ($user instanceof WP_User) { if (empty($posted_fields['password_1'])) { wc_add_notice(__('Please enter your password.', 'woocommerce'), 'error'); } if ($posted_fields['password_1'] !== $posted_fields['password_2']) { wc_add_notice(__('Passwords do not match.', 'woocommerce'), 'error'); } $errors = new WP_Error(); do_action('validate_password_reset', $errors, $user); wc_add_wp_error_notices($errors); if (0 === wc_notice_count('error')) { WC_Shortcode_My_Account::reset_password($user, $posted_fields['password_1']); do_action('woocommerce_customer_reset_password', $user); wp_redirect(add_query_arg('password-reset', 'true', wc_get_page_permalink('myaccount'))); exit; } } }
function save_wccpf_data($cart_item_data, $product_id) { $unique_cart_item_key = md5(microtime() . rand()); //$cart_item_data['wccpf_unique_key'] = $unique_cart_item_key; if ($product_id) { $val = ""; $wccpf_options = get_option('wccpf_options'); $wccpf_options = is_array($wccpf_options) ? $wccpf_options : array(); $fields_cloning = isset($wccpf_options["fields_cloning"]) ? $wccpf_options["fields_cloning"] : "no"; $all_fields = apply_filters('wcff/load/all_fields', $product_id, 'wccpf'); if ($fields_cloning == "no") { foreach ($all_fields as $fields) { foreach ($fields as $field) { $is_multi_file = isset($field["multi_file"]) ? $field["multi_file"] : "no"; if (isset($_REQUEST[$field["name"]]) || isset($_FILES[$field["name"]])) { if ($field["type"] != "checkbox" && $field["type"] != "file") { $cart_item_data["wccpf_" . $field["name"]] = $_REQUEST[$field["name"]]; } else { if ($field["type"] == "checkbox") { $cart_item_data["wccpf_" . $field["name"]] = implode(", ", $_REQUEST[$field["name"]]); } else { $res = array(); /* Handle the file upload */ if ($is_multi_file == "yes") { $files = $_FILES[$field["name"]]; foreach ($files['name'] as $key => $value) { if ($files['name'][$key]) { $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]); $temp_res = apply_filters('wccpf/upload/type=file', $file); if (isset($temp_res['error'])) { $res = $temp_res; break; } else { $res[] = $temp_res; } } } } else { $res = apply_filters('wccpf/upload/type=file', $_FILES[$field["name"]]); } if (!isset($res['error'])) { $cart_item_data["wccpf_" . $field["name"]] = json_encode($res); do_action('wccpf/uploaded/file', $res); } else { wc_add_wp_error_notices($field["message"], 'error'); } } } } } } } else { if (isset($_REQUEST["quantity"])) { $pcount = intval($_REQUEST["quantity"]); foreach ($all_fields as $fields) { foreach ($fields as $field) { $is_multi_file = isset($field["multi_file"]) ? $field["multi_file"] : "no"; for ($i = 1; $i <= $pcount; $i++) { if (isset($_REQUEST[$field["name"] . "_" . $i]) || isset($_REQUEST[$field["name"] . "_" . $i . "[]"]) || isset($_FILES[$field["name"] . "_" . $i])) { if ($field["type"] != "checkbox" && $field["type"] != "file") { $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = $_REQUEST[$field["name"] . "_" . $i]; } else { if ($field["type"] == "checkbox") { $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = implode(", ", $_REQUEST[$field["name"] . "_" . $i]); } else { $res = array(); /* Handle the file upload */ if ($is_multi_file == "yes") { $files = $_FILES[$field["name"] . "_" . $i]; foreach ($files['name'] as $key => $value) { if ($files['name'][$key]) { $file = array('name' => $files['name'][$key], 'type' => $files['type'][$key], 'tmp_name' => $files['tmp_name'][$key], 'error' => $files['error'][$key], 'size' => $files['size'][$key]); $temp_res = apply_filters('wccpf/upload/type=file', $file); if (isset($temp_res['error'])) { $res = $temp_res; break; } else { $res[] = $temp_res; } } } } else { $res = apply_filters('wccpf/upload/type=file', $_FILES[$field["name"] . "_" . $i]); } if (!isset($res['error'])) { $cart_item_data["wccpf_" . $field["name"] . "_" . $i] = json_encode($res); do_action('wccpf/uploaded/file', $res); } else { wc_add_wp_error_notices($field["message"], 'error'); } } } } } } } } } } return $cart_item_data; }